Text   |  XML   |  ReML   |   Visible Warnings:

File System Race Condition  at maildir-storage.c:694

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

maildir_list_delete_mailbox

(/home/sate/Testcases/c/cve/dovecot-1.2.0/src/lib-storage/index/maildir/maildir-storage.c)expand/collapse
Show more  
 769  maildir_list_delete_mailbox(struct mailbox_list *list, const char *name)
 770  {
 771          struct maildir_storage *storage = MAILDIR_LIST_CONTEXT(list);
 772          struct stat st;
 773          const char *src, *dest, *base;
 774          int count;
 775   
 776          /* Make sure the indexes are closed before trying to delete the 
 777             directory that contains them. It can still fail with some NFS 
 778             implementations if indexes are opened by another session, but 
 779             that can't really be helped. */
 780          index_storage_destroy_unrefed();
 781   
 782          /* delete the index and control directories */
 783          if (storage->list_module_ctx.super.delete_mailbox(list, name) < 0)
 784                  return -1;
 785   
 786          /* check if the mailbox actually exists */
 787[+]         src = mailbox_list_get_path(list, name, MAILBOX_LIST_PATH_TYPE_MAILBOX);
 788          if (lstat(src, &st) != 0 && errno == ENOENT) {
 789                  mailbox_list_set_error(list, MAIL_ERROR_NOTFOUND,
 790                          T_MAIL_ERR_MAILBOX_NOT_FOUND(name));
 791                  return -1;
 792          }
 793   
 794          if (!S_ISDIR(st.st_mode)) {
 795                  /* a symlink most likely */
 796                  if (unlink(src) < 0 && errno != ENOENT) {
 797                          mailbox_list_set_critical(list,
 798                                  "unlink(%s) failed: %m", src);
 799                          return -1;
 800                  }
 801                  return 0;
 802          }
 803   
 804          if (strcmp(name, "INBOX") == 0) {
 805                  /* we shouldn't get this far if this is the actual INBOX.
 806                     more likely we're just deleting a namespace/INBOX.
 807                     be anyway sure that we don't accidentally delete the entire
 808                     maildir (INBOX explicitly configured to maildir root). */
 809                  base = mailbox_list_get_path(list, NULL,
 810                                               MAILBOX_LIST_PATH_TYPE_MAILBOX);
 811                  if (strcmp(base, src) == 0) {
 812                          mailbox_list_set_error(list, MAIL_ERROR_NOTPOSSIBLE,
 813                                                 "INBOX can't be deleted.");
 814                          return -1;
 815                  }
 816          }
 817   
 818[+]         dest = maildir_get_unlink_dest(list, name);
 819          if (dest == NULL) {
 820                  /* delete the directory directly without any renaming */
 821[+]                 return maildir_delete_nonrecursive(list, src, name);
expand/collapse

maildir_delete_nonrecursive

(/home/sate/Testcases/c/cve/dovecot-1.2.0/src/lib-storage/index/maildir/maildir-storage.c)expand/collapse
Show more  
 685  maildir_delete_nonrecursive(struct mailbox_list *list, const char *path,
 686                              const char *name)
 687  {
 688          DIR *dir;
 689          struct dirent *d;
 690          string_t *full_path;
 691          unsigned int dir_len;
 692          bool unlinked_something = FALSE;
 693   
 694          dir = opendir(path);
Show more  
Show more  




Change Warning 7383.25724 : File System Race Condition

Priority:
State:
Finding:
Owner:
Note: