Text   |  XML   |  ReML   |   Visible Warnings:

Useless Assignment  at mail-cache-fields.c:187

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

mail_cache_header_fields_get_offset

(/home/sate/Testcases/c/cve/dovecot-1.2.0/src/lib-index/mail-cache-fields.c)expand/collapse
Show more  
 171  static int mail_cache_header_fields_get_offset(struct mail_cache *cache,
 172                                                 uint32_t *offset_r, bool map)
 173  {
 174          const struct mail_cache_header_fields *field_hdr;
 175          struct mail_cache_header_fields tmp_field_hdr;
 176          uint32_t offset = 0, next_offset;
 177          unsigned int next_count = 0;
 178          bool invalidate = FALSE;
 179          int ret;
 180   
 181          if (MAIL_CACHE_IS_UNUSABLE(cache)) {
 182                  *offset_r = 0;
 183                  return 0;
 184          }
 185   
 186          /* find the latest header */
 187          offset = 0;
 188          next_offset = cache->last_field_header_offset != 0 ?
 189                  cache->last_field_header_offset :
 190                  mail_index_offset_to_uint32(cache->hdr->field_header_offset);
 191          while (next_offset != 0) {
 192                  if (next_offset == offset) {
 193                          mail_cache_set_corrupted(cache,
 194                                  "next_offset in field header loops");
 195                          return -1;
 196                  }
 197                  offset = next_offset;
 198                  invalidate = TRUE;
 199   
 200                  if (cache->mmap_base != NULL) {
 201                          if (mail_cache_map(cache, offset,
 202                                             sizeof(*field_hdr)) < 0)
 203                                  return -1;
 204                          if (offset >= cache->mmap_length) {
 205                                  mail_cache_set_corrupted(cache,
 206                                          "header field next_offset points outside file");
 207                                  return -1;
 208                          }
 209   
 210                          field_hdr = CONST_PTR_OFFSET(cache->data, offset);
 211                  } else {
 212                          /* if we need to follow multiple offsets to get to
 213                             the last one, it's faster to just pread() the file
 214                             instead of going through cache */
 215                          ret = pread_full(cache->fd, &tmp_field_hdr,
 216                                           sizeof(tmp_field_hdr), offset);
 217                          if (ret < 0) {
 218                                  mail_cache_set_syscall_error(cache, "pread()");
 219                                  return -1;
 220                          }
 221                          if (ret == 0) {
 222                                  mail_cache_set_corrupted(cache,
 223                                          "header field next_offset points outside file");
 224                                  return -1;
 225                          }
 226                          field_hdr = &tmp_field_hdr;
 227                  }
 228   
 229                  next_offset =
 230                          mail_index_offset_to_uint32(field_hdr->next_offset);
 231                  next_count++;
 232          }
 233   
 234          if (offset == 0) {
 235                  mail_cache_set_corrupted(cache, "missing header fields");
 236                  return -1;
 237          }
 238          cache->last_field_header_offset = offset;
 239   
 240          if (next_count > MAIL_CACHE_HEADER_FIELD_CONTINUE_COUNT)
 241                  cache->need_compress_file_seq = cache->hdr->file_seq;
 242   
 243          if (map) {
 244                  if (cache->file_cache != NULL && invalidate) {
 245                          /* if this isn't the first header in file and we hadn't
 246                             read this before, we can't trust that the cached
 247                             data is valid */
 248                          file_cache_invalidate(cache->file_cache, offset,
 249                                                field_hdr->size);
 250                  }
 251                  if (mail_cache_map(cache, offset, field_hdr->size) < 0)
 252                          return -1;
 253          }
 254   
 255          *offset_r = offset;
 256          return 0;
 257  }
Show more  




Change Warning 7181.24995 : Useless Assignment

Priority:
State:
Finding:
Owner:
Note: