Text   |  XML   |  ReML   |   Visible Warnings:

Ignored Return Value  at mail-cache-lookup.c:482

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

mail_cache_lookup_headers_real

(/home/sate/Testcases/c/cve/dovecot-1.2.0/src/lib-index/mail-cache-lookup.c)expand/collapse
Show more  
 453  mail_cache_lookup_headers_real(struct mail_cache_view *view, string_t *dest,
 454                                 uint32_t seq, unsigned int field_idxs[],
 455                                 unsigned int fields_count)
 456  {
 457          struct mail_cache *cache = view->cache;
 458          struct mail_cache_lookup_iterate_ctx iter;
 459          struct mail_cache_iterate_field field;
 460          struct header_lookup_context ctx;
 461          struct header_lookup_line *lines;
 462          const unsigned char *p, *start, *end;
 463          uint8_t *field_state;
 464          unsigned int i, count, max_field = 0;
 465          size_t hdr_size;
 466          uint8_t want = HDR_FIELD_STATE_WANT;
 467          buffer_t *buf;
 468          int ret;
 469   
 470          if (fields_count == 0)
 471                  return 1;
 472   
 473          if (!view->cache->opened)
 474                  (void)mail_cache_open_and_verify(view->cache);
 475   
 476          /* update the decision state regardless of whether the fields 
 477             actually exist or not. */
 478          for (i = 0; i < fields_count; i++)
 479                  mail_cache_decision_state_update(view, seq, field_idxs[i]);
 480   
 481          /* mark all the fields we want to find. */
 482          buf = buffer_create_dynamic(pool_datastack_create(), 32);
 483          for (i = 0; i < fields_count; i++) {
 484                  if (!mail_cache_file_has_field(cache, field_idxs[i]))
 485                          return 0;
 486   
 487                  if (field_idxs[i] > max_field)
 488                          max_field = field_idxs[i];
 489   
 490                  buffer_write(buf, field_idxs[i], &want, 1);
 491          }
 492          field_state = buffer_get_modifiable_data(buf, NULL);
 493   
 494          /* lookup the fields */
 495          memset(&ctx, 0, sizeof(ctx));
 496          ctx.view = view;
 497          t_array_init(&ctx.lines, 32);
 498   
 499          mail_cache_lookup_iter_init(view, seq, &iter);
 500          while ((ret = mail_cache_lookup_iter_next(&iter, &field)) > 0) {
 501                  if (field.field_idx > max_field ||
 502                      field_state[field.field_idx] != HDR_FIELD_STATE_WANT) {
 503                          /* a) don't want it, b) duplicate */
 504                  } else {
 505                          field_state[field.field_idx] = HDR_FIELD_STATE_SEEN;
 506                          header_lines_save(&ctx, &field);
 507                  }
 508   
 509          }
 510          if (ret < 0)
 511                  return -1;
 512   
 513          /* check that all fields were found */
 514          for (i = 0; i <= max_field; i++) {
 515                  if (field_state[i] == HDR_FIELD_STATE_WANT)
 516                          return 0;
 517          }
 518   
 519          /* we need to return headers in the order they existed originally.
 520             we can do this by sorting the messages by their line numbers. */
 521          lines = array_get_modifiable(&ctx.lines, &count);
 522          qsort(lines, count, sizeof(*lines), header_lookup_line_cmp);
 523   
 524          /* then start filling dest buffer from the headers */
 525          for (i = 0; i < count; i++) {
 526                  start = CONST_PTR_OFFSET(cache->data, lines[i].data->offset);
 527                  end = start + lines[i].data->data_size;
 528   
 529                  /* find the end of the (multiline) header */
 530                  for (p = start; p != end; p++) {
 531                          if (*p == '\n' &&
 532                              (p+1 == end || (p[1] != ' ' && p[1] != '\t'))) {
 533                                  p++;
 534                                  break;
 535                          }
 536                  }
 537                  hdr_size = (size_t)(p - start);
 538                  buffer_append(dest, start, hdr_size);
 539   
 540                  /* if there are more lines for this header, the following lines 
 541                     continue after this one. so skip this line. */
 542                  lines[i].data->offset += hdr_size;
 543                  lines[i].data->data_size -= hdr_size;
 544          }
 545          return 1;
 546  }
Show more  




Change Warning 8171.26077 : Ignored Return Value

Priority:
State:
Finding:
Owner:
Note: