Text   |  XML   |  ReML   |   Visible Warnings:

File System Race Condition  at cydir-save.c:208

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

cydir_save_finish

(/home/sate/Testcases/c/cve/dovecot-1.2.0/src/lib-storage/index/cydir/cydir-save.c)expand/collapse
Show more  
 154  int cydir_save_finish(struct mail_save_context *_ctx)
 155  {
 156          struct cydir_save_context *ctx = (struct cydir_save_context *)_ctx;
 157          struct mail_storage *storage = &ctx->mbox->storage->storage;
 158[+]         const char *path = cydir_get_save_path(ctx, ctx->mail_count);
 159          struct stat st;
 160   
 161          ctx->finished = TRUE;
 162   
 163[+]         if (o_stream_flush(_ctx->output) < 0) {
 164                  mail_storage_set_critical(storage,
 165                          "o_stream_flush(%s) failed: %m", path);
 166                  ctx->failed = TRUE;
 167          }
 168   
 169          if (!ctx->mbox->ibox.fsync_disable) {
 170                  if (fsync(ctx->fd) < 0) {
 171                          mail_storage_set_critical(storage,
 172                                                    "fsync(%s) failed: %m", path);
 173                          ctx->failed = TRUE;
 174                  }
 175          }
 176   
 177          if (_ctx->received_date == (time_t)-1) {
 178                  if (fstat(ctx->fd, &st) == 0)
 179                          _ctx->received_date = st.st_mtime;
 180                  else {
 181                          mail_storage_set_critical(storage,
 182                                                    "fstat(%s) failed: %m", path);
 183                          ctx->failed = TRUE;
 184                  }
 185          } else {
 186                  struct utimbuf ut;
 187   
 188                  ut.actime = ioloop_time;
 189                  ut.modtime = _ctx->received_date;
 190                  if (utime(path, &ut) < 0) {
 191                          mail_storage_set_critical(storage,
 192                                                    "utime(%s) failed: %m", path);
 193                          ctx->failed = TRUE;
 194                  }
 195          }
 196   
 197          o_stream_destroy(&_ctx->output);
 198          if (close(ctx->fd) < 0) {
 199                  mail_storage_set_critical(storage,
 200                                            "close(%s) failed: %m", path);
 201                  ctx->failed = TRUE;
 202          }
 203          ctx->fd = -1;
 204   
 205          if (!ctx->failed)
 206                  ctx->mail_count++;
 207          else {
 208                  if (unlink(path) < 0) {
Show more  




Change Warning 7489.26056 : File System Race Condition

Priority:
State:
Finding:
Owner:
Note: