Text   |  XML   |  ReML   |   Visible Warnings:

File System Race Condition  at dbox-storage.c:431

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

dbox_delete_nonrecursive

(/home/sate/Testcases/c/cve/dovecot-1.2.0/src/lib-storage/index/dbox/dbox-storage.c)expand/collapse
Show more  
 377  dbox_delete_nonrecursive(struct mailbox_list *list, const char *path,
 378                           const char *name)
 379  {
 380          DIR *dir;
 381          struct dirent *d;
 382          string_t *full_path;
 383          unsigned int dir_len;
 384          bool unlinked_something = FALSE;
 385   
 386          dir = opendir(path);
 387          if (dir == NULL) {
 388                  if (errno == ENOENT)
 389                          return 0;
 390                  if (!mailbox_list_set_error_from_errno(list)) {
 391                          mailbox_list_set_critical(list,
 392                                  "opendir(%s) failed: %m", path);
 393                  }
 394                  return -1;
 395          }
 396   
 397          full_path = t_str_new(256);
 398          str_append(full_path, path);
 399          str_append_c(full_path, '/');
 400          dir_len = str_len(full_path);
 401   
 402          errno = 0;
 403          while ((d = readdir(dir)) != NULL) {
 404                  if (d->d_name[0] == '.') {
 405                          /* skip . and .. */
 406                          if (d->d_name[1] == '\0')
 407                                  continue;
 408                          if (d->d_name[1] == '.' && d->d_name[2] == '\0')
 409                                  continue;
 410                  }
 411   
 412                  str_truncate(full_path, dir_len);
 413                  str_append(full_path, d->d_name);
 414   
 415                  /* trying to unlink() a directory gives either EPERM or EISDIR 
 416                     (non-POSIX). it doesn't really work anywhere in practise,
 417                     so don't bother stat()ing the file first */
 418                  if (unlink(str_c(full_path)) == 0)
 419                          unlinked_something = TRUE;
 420                  else if (errno != ENOENT && errno != EISDIR && errno != EPERM) {
 421                          mailbox_list_set_critical(list, "unlink(%s) failed: %m",
 422                                                    str_c(full_path));
 423                  }
 424          }
 425   
 426          if (closedir(dir) < 0) {
 427                  mailbox_list_set_critical(list, "closedir(%s) failed: %m",
 428                                            path);
 429          }
 430   
 431          if (rmdir(path) == 0)
Show more  




Change Warning 7483.24849 : File System Race Condition

Priority:
State:
Finding:
Owner:
Note: