Text   |  XML   |  ReML   |   Visible Warnings:

Negative file descriptor  at mmap-util.c:12

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

mail_cache_lock_full

(/home/sate/Testcases/c/cve/dovecot-1.2.0/src/lib-index/mail-cache.c)expand/collapse
Show more  
 541  mail_cache_lock_full(struct mail_cache *cache, bool require_same_reset_id,
 542                       bool nonblock)
 543  {
 544          const struct mail_index_ext *ext;
 545          struct mail_index_view *iview;
 546          uint32_t reset_id;
 547          int i, ret;
 548   
 549          i_assert(!cache->locked);
 550   
 551          if (!cache->opened)
 552[+]                 (void)mail_cache_open_and_verify(cache);
 553   
 554          if (MAIL_CACHE_IS_UNUSABLE(cache) ||
 555              MAIL_INDEX_IS_IN_MEMORY(cache->index))
 556                  return 0;
 557   
 558          iview = mail_index_view_open(cache->index);
 559          ext = mail_index_view_get_ext(iview, cache->ext_id);
 560          reset_id = ext == NULL ? 0 : ext->reset_id;
 561          mail_index_view_close(&iview);
 562   
 563          if (ext == NULL && require_same_reset_id) {
 564                  /* cache not used */
 565                  return 0;
 566          }
 567   
 568          for (i = 0; i < 3; i++) {
 569                  if (cache->hdr->file_seq != reset_id &&
 570                      (require_same_reset_id || i == 0)) {
 571                          /* we want the latest cache file */
 572                          if (reset_id < cache->hdr->file_seq) {
 573                                  /* either we're still waiting for index to 
 574                                     catch up with a cache compression, or 
 575                                     that catching up is never going to happen */
 576                                  ret = 0;
 577                                  break;
 578                          }
 579                          ret = mail_cache_reopen(cache);
 580                          if (ret < 0 || (ret == 0 && require_same_reset_id))
 581                                  break;
 582                  }
 583   
 584[+]                 if ((ret = mail_cache_lock_file(cache, nonblock)) <= 0) {
 585                          ret = -1;
 586                          break;
 587                  }
 588                  cache->locked = TRUE;
 589   
 590                  if (cache->hdr->file_seq == reset_id ||
 591                      !require_same_reset_id) {
 592                          /* got it */
 593                          break;
 594                  }
 595   
 596                  /* okay, so it was just compressed. try again. */
 597                  (void)mail_cache_unlock(cache);
 598                  ret = 0;
 599          }
 600   
 601          if (ret > 0) {
 602                  /* make sure our header is up to date */
 603                  if (cache->file_cache != NULL) {
 604                          file_cache_invalidate(cache->file_cache, 0,
 605                                                sizeof(struct mail_cache_header));
 606                  }
 607[+]                 if (mail_cache_map(cache, 0, 0) == 0)
expand/collapse

mail_cache_map

(/home/sate/Testcases/c/cve/dovecot-1.2.0/src/lib-index/mail-cache.c)expand/collapse
Show more  
 266  int mail_cache_map(struct mail_cache *cache, size_t offset, size_t size)
 267  {
 268          ssize_t ret;
 269   
 270          cache->remap_counter++;
 271   
 272          if (size == 0)
 273                  size = sizeof(struct mail_cache_header);
 274   
 275          if (cache->file_cache != NULL) {
 276                  cache->data = NULL;
 277                  cache->hdr = NULL;
 278   
 279                  ret = file_cache_read(cache->file_cache, offset, size);
 280                  if (ret < 0) {
 281                          /* In case of ESTALE we'll simply fail without error
 282                             messages. The caller will then just have to 
 283                             fallback to generating the value itself.
 284   
 285                             We can't simply reopen the cache flie, because 
 286
302
Show [ Lines 286 to 302 omitted. ]
 303                          }
 304                          memcpy(&cache->hdr_ro_copy, cache->data,
 305                                 sizeof(cache->hdr_ro_copy));
 306                  }
 307                  cache->hdr = &cache->hdr_ro_copy;
 308                  if (offset == 0)
 309                          mail_cache_update_need_compress(cache);
 310                  return 0;
 311          }
 312   
 313          if (offset < cache->mmap_length &&
 314              size <= cache->mmap_length - offset) {
 315                  /* already mapped */
 316                  return 0;
 317          }
 318   
 319          if (cache->mmap_base != NULL) {
 320                  if (munmap(cache->mmap_base, cache->mmap_length) < 0)
 321                          mail_cache_set_syscall_error(cache, "munmap()");
 322          } else {
 323                  if (cache->fd == -1) {
 324                          /* unusable, waiting for compression or
 325                             index is in memory */
 326                          i_assert(cache->need_compress_file_seq != 0 ||
 327                                   MAIL_INDEX_IS_IN_MEMORY(cache->index));
 328                          return -1;
 329                  }
 330          }
 331   
 332          /* map the whole file */
 333          cache->hdr = NULL;
 334          cache->mmap_length = 0;
 335   
 336[+]         cache->mmap_base = mmap_ro_file(cache->fd, &cache->mmap_length);
expand/collapse

mmap_ro_file

(/home/sate/Testcases/c/cve/dovecot-1.2.0/src/lib/mmap-util.c)expand/collapse
Show more  
 30  void *mmap_ro_file(int fd, size_t *length)
 31  {
 32[+]         return mmap_file(fd, length, PROT_READ);
expand/collapse

mmap_file

(/home/sate/Testcases/c/cve/dovecot-1.2.0/src/lib/mmap-util.c)expand/collapse
Show more  
 8  void *mmap_file(int fd, size_t *length, int prot)
 9  {
 10          struct stat st;
 11   
 12          if (fstat(fd, &st) < 0)
Show more  
Show more  
Show more  
Show more  




Change Warning 11479.25535 : Negative file descriptor

Priority:
State:
Finding:
Owner:
Note: