Text   |  XML   |  ReML   |   Visible Warnings:

File System Race Condition  at mbox-storage.c:979

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

mbox_list_delete_mailbox

(/home/sate/Testcases/c/cve/dovecot-1.2.0/src/lib-storage/index/mbox/mbox-storage.c)expand/collapse
Show more  
 919  static int mbox_list_delete_mailbox(struct mailbox_list *list,
 920                                      const char *name)
 921  {
 922          struct mbox_storage *storage = MBOX_LIST_CONTEXT(list);
 923          struct stat st;
 924          const char *path, *index_dir;
 925   
 926          path = mailbox_list_get_path(list, name,
 927[+]                                      MAILBOX_LIST_PATH_TYPE_MAILBOX);
 928          if (lstat(path, &st) < 0) {
 929                  if (ENOTFOUND(errno)) {
 930                          mailbox_list_set_error(list, MAIL_ERROR_NOTFOUND,
 931                                  T_MAIL_ERR_MAILBOX_NOT_FOUND(name));
 932                  } else if (!mailbox_list_set_error_from_errno(list)) {
 933                          mailbox_list_set_critical(list,
 934                                  "lstat() failed for %s: %m", path);
 935                  }
 936                  return -1;
 937          }
 938   
 939          if (S_ISDIR(st.st_mode)) {
 940                  /* deleting a directory. allow it only if it doesn't contain 
 941                     anything. Delete the ".imap" directory first in case there 
 942                     have been indexes. */
 943                  index_dir = mailbox_list_get_path(list, name,
 944                                          MAILBOX_LIST_PATH_TYPE_MAILBOX);
 945                  index_dir = *index_dir == '\0' ? "" :
 946                          t_strconcat(index_dir, "/"MBOX_INDEX_DIR_NAME, NULL);
 947   
 948                  if (*index_dir != '\0' && rmdir(index_dir) < 0 &&
 949                      !ENOTFOUND(errno) && errno != ENOTEMPTY) {
 950
964
Show [ Lines 950 to 964 omitted. ]
 965                                  t_strdup_printf("Directory %s isn't empty, "
 966                                                  "can't delete it.", name));
 967                  } else if (!mailbox_list_set_error_from_errno(list)) {
 968                          mailbox_list_set_critical(list,
 969                                  "rmdir() failed for %s: %m", path);
 970                  }
 971                  return -1;
 972          }
 973   
 974          /* delete index / control files first */
 975          index_storage_destroy_unrefed();
 976          if (storage->list_module_ctx.super.delete_mailbox(list, name) < 0)
 977                  return -1;
 978   
 979          if (unlink(path) < 0) {
Show more  




Change Warning 7439.25728 : File System Race Condition

Priority:
State:
Finding:
Owner:
Note: