Text   |  XML   |  ReML   |   Visible Warnings:

File System Race Condition  at maildir-uidlist.c:1259

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

maildir_uidlist_recreate

(/home/sate/Testcases/c/cve/dovecot-1.2.0/src/lib-storage/index/maildir/maildir-uidlist.c)expand/collapse
Show more  
 1199  static int maildir_uidlist_recreate(struct maildir_uidlist *uidlist)
 1200  {
 1201          struct mailbox *box = &uidlist->ibox->box;
 1202          const char *control_dir, *temp_path;
 1203          struct stat st;
 1204          mode_t old_mask;
 1205          uoff_t file_size;
 1206          int i, fd, ret;
 1207   
 1208          i_assert(uidlist->initial_read);
 1209   
 1210          control_dir = mailbox_list_get_path(box->storage->list, box->name,
 1211                                              MAILBOX_LIST_PATH_TYPE_CONTROL);
 1212          temp_path = t_strconcat(control_dir,
 1213[+]                                 "/" MAILDIR_UIDLIST_NAME ".tmp", NULL);
 1214   
 1215          for (i = 0;; i++) {
 1216                  old_mask = umask(0777 & ~box->file_create_mode);
 1217                  fd = open(temp_path, O_RDWR | O_CREAT | O_TRUNC, 0777);
 1218                  umask(old_mask);
 1219                  if (fd != -1)
 1220                          break;
 1221   
 1222                  if (errno != ENOENT || i == MAILDIR_DELETE_RETRY_COUNT ||
 1223                      uidlist->mbox == NULL) {
 1224                          mail_storage_set_critical(box->storage,
 1225                                  "open(%s, O_CREAT) failed: %m", temp_path);
 1226                          return -1;
 1227                  }
 1228                  /* the control dir doesn't exist. create it unless the whole 
 1229                     mailbox was just deleted. */
 1230                  if (!maildir_set_deleted(uidlist->mbox))
 1231                          return -1;
 1232          }
 1233   
 1234          if (box->file_create_gid != (gid_t)-1 &&
 1235              fchown(fd, (uid_t)-1, box->file_create_gid) < 0) {
 1236                  if (errno == EPERM) {
 1237                          mail_storage_set_critical(box->storage, "%s",
 1238                                  eperm_error_get_chgrp("fchown", temp_path,
 1239                                                  box->file_create_gid,
 1240                                                  box->file_create_gid_origin));
 1241                  } else {
 1242                          mail_storage_set_critical(box->storage,
 1243                                  "fchown(%s) failed: %m", temp_path);
 1244                  }
 1245          }
 1246   
 1247          uidlist->read_records_count = 0;
 1248          ret = maildir_uidlist_write_fd(uidlist, fd, temp_path, 0, &file_size);
 1249          if (ret == 0) {
 1250                  if (rename(temp_path, uidlist->path) < 0) {
 1251                          mail_storage_set_critical(box->storage,
 1252                                  "rename(%s, %s) failed: %m",
 1253                                  temp_path, uidlist->path);
 1254                          ret = -1;
 1255                  }
 1256          }
 1257   
 1258          if (ret < 0) {
 1259                  if (unlink(temp_path) < 0) {
Show more  




Change Warning 7312.25169 : File System Race Condition

Priority:
State:
Finding:
Owner:
Note: