Text   |  XML   |  ReML   |   Visible Warnings:

File System Race Condition  at acl-backend-vfile-acllist.c:98

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

acl_backend_vfile_acllist_read

(/home/sate/Testcases/c/cve/dovecot-1.2.0/src/plugins/acl/acl-backend-vfile-acllist.c)expand/collapse
Show more  
 41  static int acl_backend_vfile_acllist_read(struct acl_backend_vfile *backend)
 42  {
 43          struct acl_backend_vfile_acllist acllist;
 44          struct istream *input;
 45          struct stat st;
 46          const char *rootdir, *path, *line, *p;
 47          int fd, ret = 0;
 48   
 49          backend->acllist_last_check = ioloop_time;
 50   
 51          rootdir = mailbox_list_get_path(backend->backend.list, NULL,
 52[+]                                         MAILBOX_LIST_PATH_TYPE_DIR);
 53          if (rootdir == NULL) {
 54                  /* we're never going to build acllist for this namespace. */
 55                  i_array_init(&backend->acllist, 1);
 56                  return 0;
 57          }
 58[+]         path = t_strdup_printf("%s/"ACLLIST_FILENAME, rootdir);
 59   
 60          if (backend->acllist_mtime != 0) {
 61                  /* see if the file's mtime has changed */
 62                  if (stat(path, &st) < 0) {
 63                          if (errno == ENOENT)
 64                                  backend->acllist_mtime = 0;
 65                          else 
 66                                  i_error("stat(%s) failed: %m", path);
 67                          return -1;
 68                  }
 69                  if (st.st_mtime == backend->acllist_mtime)
 70                          return 0;
 71          }
 72   
 73          fd = open(path, O_RDONLY);
 74          if (fd == -1) {
 75                  if (errno == ENOENT) {
 76                          backend->acllist_mtime = 0;
 77                          return -1;
 78                  }
 79                  i_error("open(%s) failed: %m", path);
 80                  return -1;
 81          }
 82          if (fstat(fd, &st) < 0) {
 83                  i_error("fstat(%s) failed: %m", path);
 84                  (void)close(fd);
 85                  return -1;
 86          }
 87          backend->acllist_mtime = st.st_mtime;
 88          acllist_clear(backend, st.st_size);
 89   
 90          input = i_stream_create_fd(fd, (size_t)-1, FALSE);
 91[+]         while ((line = i_stream_read_next_line(input)) != NULL) {
 92                  acllist.mtime = 0;
 93                  for (p = line; *p >= '0' && *p <= '9'; p++)
 94                          acllist.mtime = acllist.mtime * 10 + (*p - '0');
 95   
 96                  if (p == line || *p != ' ' || p[1] == '\0') {
 97                          i_error("Broken acllist file: %s", path);
 98                          if (unlink(path) < 0 && errno != ENOENT)
 99                                  i_error("unlink(%s) failed: %m", path);
 100                          return -1;
 101                  }
 102                  acllist.name = p_strdup(backend->acllist_pool, p + 1);
 103                  array_append(&backend->acllist, &acllist, 1);
Show more  




Change Warning 8046.24784 : File System Race Condition

Priority:
State:
Finding:
Owner:
Note: