(/home/sate/Testcases/c/cve/dovecot-1.2.0/src/lib-storage/index/maildir/maildir-save.c) |
| |
| 435 | | | static int maildir_save_finish_real(struct mail_save_context *_ctx) |
| 436 | | | { |
| 437 | | | struct maildir_save_context *ctx = (struct maildir_save_context *)_ctx; |
| 438 | | | struct mail_storage *storage = &ctx->mbox->storage->storage; |
| 439 | | | struct utimbuf buf; |
| 440 | | | struct stat st; |
| 441 | | | const char *path; |
| 442 | | | int output_errno; |
| 443 | | | |
| 444 | | | ctx->finished = TRUE; |
| 445 | | | if (ctx->failed && ctx->fd == -1) { |
| 446 | | | |
| 447 | | | return -1; |
| 448 | | | } |
| 449 | | | |
| 450 | | | path = t_strconcat(ctx->tmpdir, "/", ctx->file_last->basename, NULL); |
Ignored Return Value
The return value of t_strconcat() is never checked in the highlighted execution scenario. - If the return value can indicate an error, the error will be ignored if the highlighted code executes.
- The return value of t_strconcat() is checked 98% of the time in this project. CodeSonar is configured to enforce Ignored Return Value checks for any function whose return value is checked at least 96% of the time, unless the function is used fewer than 20 times. (To modify these thresholds, use configuration file parameters RETURN_CHECKER_SAMPLE_SIZE and RETURN_CHECKER_RATIO. To exempt t_strconcat() from the Ignored Return Value check, use configuration file parameter RETURN_CHECKER_IGNORED_FUNCS).
Show: All events | Only primary events |
|
| 451 | | | if (o_stream_flush(_ctx->output) < 0) { |
Event 2:
Skipping " if". o_stream_flush(...) < 0 evaluates to false.
hide
|
|
| 452 | | | if (!mail_storage_set_error_from_errno(storage)) { |
| 453 | | | mail_storage_set_critical(storage, |
| 454 | | | "o_stream_flush(%s) failed: %m", path); |
| 455 | | | } |
| 456 | | | ctx->failed = TRUE; |
| 457 | | | } |
| 458 | | | |
| 459 | | | if (ctx->ctx.received_date != (time_t)-1) { |
Event 3:
Taking false branch. ctx->ctx.received_date != (time_t)-1 evaluates to false.
hide
|
|
| 460 | | | |
| 461 | | | buf.actime = ioloop_time; |
| 462 | | | buf.modtime = ctx->ctx.received_date; |
| 463 | | | |
| 464 | | | if (utime(path, &buf) < 0) { |
| 465 | | | ctx->failed = TRUE; |
| 466 | | | mail_storage_set_critical(storage, |
| 467 | | | "utime(%s) failed: %m", path); |
| 468 | | | } |
| 469 | | | } else if (ctx->fd != -1) { |
Event 4:
Taking true branch. ctx->fd != -1 evaluates to true.
hide
|
|
| 470 | | | if (fstat(ctx->fd, &st) == 0) |
Event 5:
Taking true branch. fstat(ctx->fd, &st) == 0 evaluates to true.
hide
|
|
| 471 | | | ctx->ctx.received_date = st.st_mtime;
x /usr/include/bits/stat.h |
| |
95 | # define st_mtime st_mtim.tv_sec |
| |
|
| 472 | | | else { |
| 473 | | | ctx->failed = TRUE; |
| 474 | | | mail_storage_set_critical(storage, |
| 475 | | | "fstat(%s) failed: %m", path); |
| 476 | | | } |
| 477 | | | } else { |
| 478 | | | |
| 479 | | | if (stat(path, &st) == 0) |
| 480 | | | ctx->ctx.received_date = st.st_mtime;
x /usr/include/bits/stat.h |
| |
95 | # define st_mtime st_mtim.tv_sec |
| |
|
| 481 | | | else { |
| 482 | | | ctx->failed = TRUE; |
| 483 | | | mail_storage_set_critical(storage, |
| 484 | | | "stat(%s) failed: %m", path); |
| 485 | | | } |
| 486 | | | } |
| 487 | | | |
| 488 | | | if (ctx->cur_dest_mail != NULL) { |
Event 6:
Taking true branch. ctx->cur_dest_mail != (void *)0 evaluates to true.
hide
|
|
| 489 | | | index_mail_cache_parse_deinit(ctx->cur_dest_mail, |
| 490 | | | ctx->ctx.received_date, |
| 491 | | | !ctx->failed); |
Event 7:
!ctx->failed evaluates to true.
hide
|
|
| 492 | | | } |
| 493 | | | i_stream_unref(&ctx->input); |
| 494 | | | |
| 495 | | | |
| 496 | | | ctx->file_last->size = _ctx->output->offset; |
| 497 | | | if (ctx->cur_dest_mail == NULL || |
Event 8:
Skipping " if". - ctx->cur_dest_mail == (void *)0 evaluates to false.
- mail_get_virtual_size(...) < 0 evaluates to false.
hide
|
|
| 498 | | | mail_get_virtual_size(ctx->cur_dest_mail, |
| 499 | | | &ctx->file_last->vsize) < 0) |
| 500 | | | ctx->file_last->vsize = (uoff_t)-1; |
| 501 | | | |
| 502 | | | output_errno = _ctx->output->stream_errno; |
| 503 | | | o_stream_destroy(&_ctx->output); |
| 504 | | | |
| 505 | | | if (!ctx->mbox->ibox.fsync_disable && !ctx->failed) { |
Event 9:
Skipping " if". ctx->mbox->ibox.fsync_disable evaluates to true.
hide
|
|
| 506 | | | if (fsync(ctx->fd) < 0) { |
| 507 | | | if (!mail_storage_set_error_from_errno(storage)) { |
| 508 | | | mail_storage_set_critical(storage, |
| 509 | | | "fsync(%s) failed: %m", path); |
| 510 | | | } |
| 511 | | | ctx->failed = TRUE; |
| 512 | | | } |
| 513 | | | } |
| 514 | | | if (close(ctx->fd) < 0) { |
Event 10:
Skipping " if". close(ctx->fd) < 0 evaluates to false.
hide
|
|
| 515 | | | if (!mail_storage_set_error_from_errno(storage)) { |
| 516 | | | mail_storage_set_critical(storage, |
| 517 | | | "close(%s) failed: %m", path); |
| 518 | | | } |
| 519 | | | ctx->failed = TRUE; |
| 520 | | | } |
| 521 | | | ctx->fd = -1; |
| 522 | | | |
| 523 | | | if (ctx->failed) { |
Event 11:
Skipping " if". ctx->failed evaluates to false.
hide
|
|
| 524 | | | struct maildir_filename **fm; |
| 525 | | | |
| 526 | | | |
| 527 | | | if (unlink(path) < 0 && errno != ENOENT) {
x /usr/include/asm-generic/errno-base.h |
| |
5 | #define ENOENT 2 /* No such file or directory */ |
| |
|
| 528 | | | mail_storage_set_critical(storage, |
| 529 | | | "unlink(%s) failed: %m", path); |
| 530 | | | } |
| 531 | | | |
| 532 | | | errno = output_errno; |
| 533 | | | if (ENOSPACE(errno)) {
x /home/sate/Testcases/c/cve/dovecot-1.2.0/src/lib/compat.h |
| |
233 | # define ENOSPACE(errno) ((errno) == ENOSPC || (errno) == EDQUOT) |
| |
x /usr/include/asm-generic/errno-base.h |
| |
31 | #define ENOSPC 28 /* No space left on device */ |
| |
x /usr/include/asm-generic/errno.h |
| |
95 | #define EDQUOT 122 /* Quota exceeded */ |
| |
|
| 534 | | | mail_storage_set_error(storage, |
| 535 | | | MAIL_ERROR_NOSPACE, MAIL_ERRSTR_NO_SPACE); |
| 536 | | | } else if (errno != 0) { |
| 537 | | | mail_storage_set_critical(storage, |
| 538 | | | "write(%s) failed: %m", ctx->mbox->path); |
| 539 | | | } |
| 540 | | | |
| 541 | | | |
| 542 | | | for (fm = &ctx->files; (*fm)->next != NULL; fm = &(*fm)->next) ; |
| 543 | | | i_assert(*fm == ctx->file_last);
x /home/sate/Testcases/c/cve/dovecot-1.2.0/src/lib/macros.h |
| |
189 | #define i_assert(expr) STMT_START{ \ |
190 | if (unlikely(!(expr))) \ |
191 | i_panic("file %s: line %d (%s): assertion failed: (%s)", \ |
192 | __FILE__, \ |
193 | __LINE__, \ |
194 | __PRETTY_FUNCTION__, \ |
195 | #expr); }STMT_END |
| |
|
| 544 | | | *fm = NULL; |
| 545 | | | ctx->files_tail = fm; |
| 546 | | | ctx->file_last = NULL; |
| 547 | | | ctx->files_count--; |
| 548 | | | return -1; |
| 549 | | | } |
| 550 | | | |
| 551 | | | ctx->file_last = NULL; |
| 552 | | | return 0; |
| 553 | | | } |
| |