Text   |  XML   |  ReML   |   Visible Warnings:

File System Race Condition  at cydir-storage.c:291

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

cydir_delete_nonrecursive

(/home/sate/Testcases/c/cve/dovecot-1.2.0/src/lib-storage/index/cydir/cydir-storage.c)expand/collapse
Show more  
 239  cydir_delete_nonrecursive(struct mailbox_list *list, const char *path,
 240                            const char *name)
 241  {
 242          DIR *dir;
 243          struct dirent *d;
 244          string_t *full_path;
 245          unsigned int dir_len;
 246          bool unlinked_something = FALSE;
 247   
 248          dir = opendir(path);
 249          if (dir == NULL) {
 250                  if (!mailbox_list_set_error_from_errno(list)) {
 251                          mailbox_list_set_critical(list,
 252                                  "opendir(%s) failed: %m", path);
 253                  }
 254                  return -1;
 255          }
 256   
 257          full_path = t_str_new(256);
 258          str_append(full_path, path);
 259          str_append_c(full_path, '/');
 260          dir_len = str_len(full_path);
 261   
 262          errno = 0;
 263          while ((d = readdir(dir)) != NULL) {
 264                  if (d->d_name[0] == '.') {
 265                          /* skip . and .. */
 266                          if (d->d_name[1] == '\0')
 267                                  continue;
 268                          if (d->d_name[1] == '.' && d->d_name[2] == '\0')
 269                                  continue;
 270                  }
 271   
 272                  str_truncate(full_path, dir_len);
 273                  str_append(full_path, d->d_name);
 274   
 275                  /* trying to unlink() a directory gives either EPERM or EISDIR 
 276                     (non-POSIX). it doesn't really work anywhere in practise,
 277                     so don't bother stat()ing the file first */
 278                  if (unlink(str_c(full_path)) == 0)
 279                          unlinked_something = TRUE;
 280                  else if (errno != ENOENT && errno != EISDIR && errno != EPERM) {
 281                          mailbox_list_set_critical(list, "unlink(%s) failed: %m",
 282                                                    str_c(full_path));
 283                  }
 284          }
 285   
 286          if (closedir(dir) < 0) {
 287                  mailbox_list_set_critical(list, "closedir(%s) failed: %m",
 288                                            path);
 289          }
 290   
 291          if (rmdir(path) == 0)
Show more  




Change Warning 7498.24850 : File System Race Condition

Priority:
State:
Finding:
Owner:
Note: