We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Cloned from Pagure issue: https://pagure.io/SSSD/sssd/issue/1071
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
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
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
rhbz: => 0
Comment from sgallagh at 2017-02-24 15:05:26
Metadata Update from @sgallagh:
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Cloned from Pagure issue: https://pagure.io/SSSD/sssd/issue/1071
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:
The text was updated successfully, but these errors were encountered: