Text   |  XML   |  ReML   |   Visible Warnings:

Ignored Return Value  at maildir-save.c:450

No properties have been set. | edit properties
Jump to warning location ↓ warning details...
Show Events | Options

maildir_save_finish_real

(/home/sate/Testcases/c/cve/dovecot-1.2.0/src/lib-storage/index/maildir/maildir-save.c)expand/collapse
Show more  
 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                  /* tmp file creation failed */
 447                  return -1;
 448          }
 449   
 450          path = t_strconcat(ctx->tmpdir, "/", ctx->file_last->basename, NULL);
 451          if (o_stream_flush(_ctx->output) < 0) {
 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) {
 460                  /* set the received_date by modifying mtime */
 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) {
 470                  if (fstat(ctx->fd, &st) == 0)
 471                          ctx->ctx.received_date = st.st_mtime;
 472                  else {
 473                          ctx->failed = TRUE;
 474                          mail_storage_set_critical(storage,
 475                                                    "fstat(%s) failed: %m", path);
 476                  }
 477          } else {
 478                  /* hardlinked */
 479                  if (stat(path, &st) == 0)
 480                          ctx->ctx.received_date = st.st_mtime;
 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) {
 489                  index_mail_cache_parse_deinit(ctx->cur_dest_mail,
 490                                                ctx->ctx.received_date,
 491                                                !ctx->failed);
 492          }
 493          i_stream_unref(&ctx->input);
 494   
 495          /* remember the size in case we want to add it to filename */
 496          ctx->file_last->size = _ctx->output->offset;
 497          if (ctx->cur_dest_mail == NULL ||
 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) {
 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) {
 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) {
 524                  struct maildir_filename **fm;
 525   
 526                  /* delete the tmp file */
 527                  if (unlink(path) < 0 && errno != ENOENT) {
 528                          mail_storage_set_critical(storage,
 529                                  "unlink(%s) failed: %m", path);
 530                  }
 531   
 532                  errno = output_errno;
 533                  if (ENOSPACE(errno)) {
 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                  /* remove from the linked list */
 542                  for (fm = &ctx->files; (*fm)->next != NULL; fm = &(*fm)->next) ;
 543                  i_assert(*fm == ctx->file_last);
 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  }
Show more  




Change Warning 8182.26091 : Ignored Return Value

Priority:
State:
Finding:
Owner:
Note: