Text   |  XML   |  ReML   |   Visible Warnings:

File System Race Condition  at virtual-storage.c:440

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

virtual_delete_nonrecursive

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




Change Warning 8147.24864 : File System Race Condition

Priority:
State:
Finding:
Owner:
Note: