Text   |  XML   |  ReML   |   Visible Warnings:

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

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

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);
 695          if (dir == NULL) {
 696                  if (errno == ENOENT) {
 697                          mailbox_list_set_error(list, MAIL_ERROR_NOTFOUND,
 698                                  T_MAIL_ERR_MAILBOX_NOT_FOUND(name));
 699                  } else {
 700                          mailbox_list_set_critical(list,
 701                                  "opendir(%s) failed: %m", path);
 702                  }
 703                  return -1;
 704          }
 705   
 706          full_path = t_str_new(256);
 707          str_append(full_path, path);
 708          str_append_c(full_path, '/');
 709          dir_len = str_len(full_path);
 710   
 711          errno = 0;
 712          while ((d = readdir(dir)) != NULL) {
 713                  if (d->d_name[0] == '.') {
 714                          /* skip . and .. */
 715                          if (d->d_name[1] == '\0')
 716                                  continue;
 717                          if (d->d_name[1] == '.' && d->d_name[2] == '\0')
 718                                  continue;
 719                  }
 720   
 721                  str_truncate(full_path, dir_len);
 722                  str_append(full_path, d->d_name);
 723   
 724                  if (maildir_is_internal_name(d->d_name)) {
 725                          if (unlink_directory(str_c(full_path), TRUE) < 0) {
 726                                  mailbox_list_set_critical(list,
 727                                          "unlink_directory(%s) failed: %m",
 728                                          str_c(full_path));
 729                          } else {
 730                                  unlinked_something = TRUE;
 731                          }
 732                          continue;
 733                  }
 734   
 735                  /* trying to unlink() a directory gives either EPERM or EISDIR 
 736                     (non-POSIX). it doesn't really work anywhere in practise,
 737                     so don't bother stat()ing the file first */
 738                  if (unlink(str_c(full_path)) == 0)
 739                          unlinked_something = TRUE;
 740                  else if (errno != ENOENT && errno != EISDIR && errno != EPERM) {
 741                          mailbox_list_set_critical(list,
 742                                  "unlink_directory(%s) failed: %m",
 743                                  str_c(full_path));
 744                  }
 745          }
 746   
 747          if (closedir(dir) < 0) {
 748                  mailbox_list_set_critical(list, "closedir(%s) failed: %m",
 749                                            path);
 750          }
 751   
 752          if (rmdir(path) == 0)
Show more  




Change Warning 7380.24847 : File System Race Condition

Priority:
State:
Finding:
Owner:
Note: