Text   |  XML   |  ReML   |   Visible Warnings:

File System Race Condition  at unlink-old-files.c:66

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

unlink_old_files_real

(/home/sate/Testcases/c/cve/dovecot-1.2.0/src/lib/unlink-old-files.c)expand/collapse
Show more  
 16  unlink_old_files_real(const char *dir, const char *prefix, time_t min_time)
 17  {
 18          DIR *dirp;
 19          struct dirent *d;
 20          struct stat st;
 21          string_t *path;
 22          unsigned int prefix_len, dir_len;
 23   
 24          dirp = opendir(dir);
 25          if (dirp == NULL) {
 26                  if (errno != ENOENT)
 27                          i_error("opendir(%s) failed: %m", dir);
 28                  return -1;
 29          }
 30   
 31          path = t_str_new(256);
 32          str_printfa(path, "%s/", dir);
 33          dir_len = str_len(path);
 34   
 35          prefix_len = strlen(prefix);
 36          while ((d = readdir(dirp)) != NULL) {
 37                  if (d->d_name[0] == '.' &&
 38                      (d->d_name[1] == '\0' ||
 39                       (d->d_name[1] == '.' && d->d_name[2] == '\0'))) {
 40                          /* skip . and .. */
 41                          continue;
 42                  }
 43                  if (strncmp(d->d_name, prefix, prefix_len) != 0)
 44                          continue;
 45   
 46                  str_truncate(path, dir_len);
 47                  str_append(path, d->d_name);
 48                  if (stat(str_c(path), &st) < 0) {
 49                          if (errno != ENOENT)
 50                                  i_error("stat(%s) failed: %m", str_c(path));
 51                  } else if (!S_ISDIR(st.st_mode) && st.st_ctime < min_time) {
 52                          if (unlink(str_c(path)) < 0 && errno != ENOENT)
 53                                  i_error("unlink(%s) failed: %m", str_c(path));
 54                  }
 55          }
 56   
 57  #ifdef HAVE_DIRFD 
 58          if (fstat(dirfd(dirp), &st) < 0)
 59                  i_error("fstat(%s) failed: %m", dir);
 60  #else
 61          if (stat(dir, &st) < 0)
 62                  i_error("stat(%s) failed: %m", dir);
 63  #endif
 64          else if (st.st_atime < ioloop_time) {
 65                  /* mounted with noatime. update it ourself. */
 66                  if (utime(dir, NULL) < 0 && errno != ENOENT)
Show more  




Change Warning 7139.24748 : File System Race Condition

Priority:
State:
Finding:
Owner:
Note: