Text   |  XML   |  ReML   |   Visible Warnings:

File System Race Condition  at lazy-expunge-plugin.c:369

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

dir_move_or_merge

(/home/sate/Testcases/c/cve/dovecot-1.2.0/src/plugins/lazy-expunge/lazy-expunge-plugin.c)expand/collapse
Show more  
 309  static int dir_move_or_merge(struct mailbox_list *list,
 310                               const char *srcdir, const char *destdir)
 311  {
 312          DIR *dir;
 313          struct dirent *dp;
 314          string_t *src_path, *dest_path;
 315          unsigned int src_dirlen, dest_dirlen;
 316          int ret = 0;
 317   
 318          if (rename(srcdir, destdir) == 0 || errno == ENOENT)
 319                  return 0;
 320   
 321          if (!EDESTDIREXISTS(errno)) {
 322                  mailbox_list_set_critical(list,
 323                          "rename(%s, %s) failed: %m", srcdir, destdir);
 324          }
 325   
 326          /* rename all the files separately */
 327          dir = opendir(srcdir);
 328          if (dir == NULL) {
 329                  mailbox_list_set_critical(list,
 330                          "opendir(%s) failed: %m", srcdir);
 331                  return -1;
 332          }
 333   
 334          src_path = t_str_new(512);
 335          dest_path = t_str_new(512);
 336   
 337          str_append(src_path, srcdir);
 338          str_append(dest_path, destdir);
 339          str_append_c(src_path, '/');
 340          str_append_c(dest_path, '/');
 341          src_dirlen = str_len(src_path);
 342          dest_dirlen = str_len(dest_path);
 343   
 344          while ((dp = readdir(dir)) != NULL) {
 345                  if (dp->d_name[0] == '.' &&
 346                      (dp->d_name[1] == '\0' ||
 347                       (dp->d_name[1] == '.' && dp->d_name[2] == '\0')))
 348                          continue;
 349   
 350                  str_truncate(src_path, src_dirlen);
 351                  str_append(src_path, dp->d_name);
 352                  str_truncate(dest_path, dest_dirlen);
 353                  str_append(dest_path, dp->d_name);
 354   
 355                  if (rename(str_c(src_path), str_c(dest_path)) < 0 &&
 356                      errno != ENOENT) {
 357                          mailbox_list_set_critical(list,
 358                                  "rename(%s, %s) failed: %m",
 359                                  str_c(src_path), str_c(dest_path));
 360                          ret = -1;
 361                  }
 362          }
 363          if (closedir(dir) < 0) {
 364                  mailbox_list_set_critical(list,
 365                          "closedir(%s) failed: %m", srcdir);
 366                  ret = -1;
 367          }
 368          if (ret == 0) {
 369                  if (rmdir(srcdir) < 0) {
Show more  




Change Warning 8113.24844 : File System Race Condition

Priority:
State:
Finding:
Owner:
Note: