Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible resource leak in create_mail_spool() #2113

Closed
sssd-bot opened this issue May 2, 2020 · 0 comments
Closed

Possible resource leak in create_mail_spool() #2113

sssd-bot opened this issue May 2, 2020 · 0 comments
Labels
Closed: Fixed Issue was closed as fixed.

Comments

@sssd-bot
Copy link

sssd-bot commented May 2, 2020

Cloned from Pagure issue: https://pagure.io/SSSD/sssd/issue/1071

  • Created at 2011-10-28 14:18:23 by sgallagh
  • Closed as Fixed
  • Assigned to jzeleny

406int create_mail_spool(TALLOC_CTX *mem_ctx,
407 const char *username,
408 const char *maildir,
409 uid_t uid, gid_t gid)
410{
411 char *spool_file = NULL;
412 int fd;
413 int ret;
414
415 spool_file = talloc_asprintf(mem_ctx, "%s/%s", maildir, username);
416 if (spool_file == NULL) {
417 ret = ENOMEM;
418 goto fail;
419 }
420
421 selinux_file_context(spool_file);
422
CID 11082: Resource leak (RESOURCE_LEAK)Calling opening function "open".
Assigning: "fd" = handle returned from "open(spool_file, 193, 0)".
423 fd = open(spool_file, O_CREAT | O_WRONLY | O_EXCL, 0);
At conditional (1): "fd < 0" taking the false branch.
424 if (fd < 0) {
425 ret = errno;
426 DEBUG(1, ("Cannot open() the spool file: [%d][%s]\n",
427 ret, strerror(ret)));
428 goto fail;
429 }
430
Variable "fd" is not closed or saved in function "fchmod".
431 ret = fchmod(fd, 0600);
At conditional (2): "ret != 0" taking the true branch.
432 if (ret != 0) {
433 ret = errno;
At conditional (3): "1 <= debug_level" taking the true branch.
At conditional (4): "debug_timestamps" taking the true branch.
434 DEBUG(1, ("Cannot fchmod() the spool file: [%d][%s]\n",
435 ret, strerror(ret)));
436 goto fail;
437 }
438
Variable "fd" is not closed or saved in function "fchown".
439 ret = fchown(fd, uid, gid);
440 if (ret != 0) {
441 ret = errno;
442 DEBUG(1, ("Cannot fchown() the spool file: [%d][%s]\n",
443 ret, strerror(ret)));
444 goto fail;
445 }
446
Variable "fd" is not closed or saved in function "fsync".
447 ret = fsync(fd);
448 if (ret != 0) {
449 ret = errno;
450 DEBUG(1, ("Cannot fsync() the spool file: [%d][%s]\n",
451 ret, strerror(ret)));
452 goto fail;
453 }
454
455 ret = close(fd);
456 if (ret != 0) {
457 ret = errno;
458 DEBUG(1, ("Cannot close() the spool file: [%d][%s]\n",
459 ret, strerror(ret)));
460 goto fail;
461 }
462
463fail:
464 reset_selinux_file_context();
465 talloc_free(spool_file);
Handle variable "fd" going out of scope leaks the handle.
466 return ret;
467}
468

Comments


Comment from dpal at 2011-11-03 14:41:12

Fields changed

milestone: NEEDS_TRIAGE => SSSD 1.7.0


Comment from jzeleny at 2011-11-04 10:32:35

Fields changed

patch: 0 => 1
status: new => assigned


Comment from jzeleny at 2011-11-07 16:13:07

Fixed in: 5a66e8f

resolution: => fixed
status: assigned => closed


Comment from sgallagh at 2012-01-30 22:12:50

Fields changed

rhbz: => 0


Comment from sgallagh at 2017-02-24 15:05:26

Metadata Update from @sgallagh:

  • Issue assigned to jzeleny
  • Issue set to the milestone: SSSD 1.7.0
@sssd-bot sssd-bot added the Closed: Fixed Issue was closed as fixed. label May 2, 2020
@sssd-bot sssd-bot closed this as completed May 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Closed: Fixed Issue was closed as fixed.
Projects
None yet
Development

No branches or pull requests

1 participant