Text   |  XML   |  ReML   |   Visible Warnings:

Return Pointer to Freed  at index-storage.c:213

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

index_storage_alloc

(/home/sate/Testcases/c/cve/dovecot-1.2.0/src/lib-storage/index/index-storage.c)expand/collapse
Show more  
 148  struct mail_index *
 149  index_storage_alloc(struct mail_storage *storage, const char *name,
 150                      enum mailbox_open_flags flags, const char *prefix)
 151  {
 152          struct index_list **list, *rec;
 153          struct mail_index *index;
 154          struct stat st, st2;
 155          const char *index_dir, *mailbox_path;
 156          int destroy_count;
 157   
 158          mailbox_path = mailbox_list_get_path(storage->list, name,
 159                                               MAILBOX_LIST_PATH_TYPE_MAILBOX);
 160          index_dir = get_index_dir(storage, name, flags, &st);
 161   
 162          if (index_dir == NULL)
 163                  memset(&st, 0, sizeof(st));
 164   
 165          /* compare index_dir inodes so we don't break even with symlinks.
 166             for in-memory indexes compare just mailbox paths */
 167          destroy_count = 0; index = NULL;
 168          for (list = &indexes; *list != NULL;) {
 169                  rec = *list;
 170   
 171                  if (index_dir != NULL) {
 172                          if (index == NULL && st.st_ino == rec->index_dir_ino &&
 173                              CMP_DEV_T(st.st_dev, rec->index_dir_dev)) {
 174                                  /* make sure the directory still exists.
 175                                     it might have been renamed and we're trying 
 176                                     to access it via its new path now. */
 177                                  if (stat(rec->index->dir, &st2) < 0 ||
 178                                      st2.st_ino != st.st_ino ||
 179                                      !CMP_DEV_T(st2.st_dev, st.st_dev))
 180                                          rec->destroy_time = 0;
 181                                  else {
 182                                          rec->refcount++;
 183                                          index = rec->index;
 184                                  }
 185                          }
 186                  } else {
 187                          if (index == NULL && st.st_ino == 0 &&
 188                              strcmp(mailbox_path, rec->mailbox_path) == 0) {
 189                                  rec->refcount++;
 190                                  index = rec->index;
 191                          }
 192                  }
 193   
 194                  if (rec->refcount == 0) {
 195                          if (rec->destroy_time <= ioloop_time ||
 196                              destroy_count >= INDEX_CACHE_MAX) {
 197                                  *list = rec->next;
 198[+]                                 index_list_free(rec);
 199                                  continue;
 200                          } else {
 201                                  destroy_count++;
 202                          }
 203                  }
 204   
 205                  list = &(*list)->next;
 206          }
 207   
 208          if (index == NULL) {
 209                  index = mail_index_alloc(index_dir, prefix);
 210                  index_storage_add(index, mailbox_path, &st);
 211          }
 212   
 213          return index;
Show more  




Change Warning 11624.25673 : Return Pointer to Freed

Priority:
State:
Finding:
Owner:
Note: