(/home/sate/Testcases/c/cve/dovecot-1.2.0/src/util/idxview.c) |
| |
| 271 | | | static void dump_cache(struct mail_cache_view *cache_view, unsigned int seq) |
| 272 | | | { |
| 273 | | | struct mail_cache_lookup_iterate_ctx iter; |
| 274 | | | const struct mail_cache_record *prev_rec = NULL; |
| 275 | | | const struct mail_cache_field *field; |
| 276 | | | struct mail_cache_iterate_field iter_field; |
| 277 | | | const void *data; |
| 278 | | | unsigned int size; |
| 279 | | | string_t *str; |
| 280 | | | int ret; |
| 281 | | | |
| 282 | | | str = t_str_new(512); |
| 283 | | | mail_cache_lookup_iter_init(cache_view, seq, &iter); |
| 284 | | | while ((ret = mail_cache_lookup_iter_next(&iter, &iter_field)) > 0) { |
| 285 | | | if (iter.rec != prev_rec) { |
| 286 | | | printf(" - cache offset=%u size=%u, prev_offset = %u\n", |
| 287 | | | iter.offset, iter.rec->size, |
| 288 | | | iter.rec->prev_offset); |
| 289 | | | prev_rec = iter.rec; |
| 290 | | | } |
| 291 | | | |
| 292 | | | field = &cache_view->cache->fields[iter_field.field_idx].field; |
| 293 | | | data = iter_field.data; |
| 294 | | | size = iter_field.size; |
| 295 | | | |
| 296 | | | str_truncate(str, 0); |
| 297 | | | str_printfa(str, " - %s: ", field->name); |
| 298 | | | switch (field->type) { |
| 299 | | | case MAIL_CACHE_FIELD_FIXED_SIZE: |
| 300 | | | if (size == sizeof(uint32_t)) |
| 301 | | | str_printfa(str, "%u ", *((const uint32_t *)data)); |
| 302 | | | else if (size == sizeof(uint64_t)) |
| 303 | | | str_printfa(str, "%llu ", (unsigned long long)*((const uint64_t *)data)); |
| 304 | | | case MAIL_CACHE_FIELD_VARIABLE_SIZE: |
| 305 | | | case MAIL_CACHE_FIELD_BITMASK: |
| 306 | | | str_printfa(str, "(%s)", binary_to_hex(data, size)); |
| 307 | | | break; |
| 308 | | | case MAIL_CACHE_FIELD_STRING: |
| 309 | | | if (size > 0) |
| 310 | | | str_printfa(str, "%.*s", (int)size, (const char *)data); |
| 311 | | | break; |
| 312 | | | case : { |
| 313 | | | const uint32_t *lines = data; |
| 314 | | | int i; |
| 315 | | | |
| 316 | | | for (i = 0;; i++) { |
| 317 | | | if (size < sizeof(uint32_t)) { |
| 318 | | | if (i == 0 && size == 0) { |
| 319 | | | |
| 320 | | | break; |
| 321 | | | } |
| 322 | | | |
| 323 | | | str_append(str, "\n - BROKEN: field doesn't end with 0 line"); |
| 324 | | | size = 0; |
| 325 | | | break; |
| 326 | | | } |
| 327 | | | |
| 328 | | | size -= sizeof(uint32_t); |
| 329 | | | data = CONST_PTR_OFFSET(data, sizeof(uint32_t));
x /home/sate/Testcases/c/cve/dovecot-1.2.0/src/lib/macros.h |
| |
29 | #define CONST_PTR_OFFSET(ptr, offset) \ |
30 | ((const void *) (((const unsigned char *) (ptr)) + (offset))) |
| |
|
| 330 | | | if (lines[i] == 0) |
| 331 | | | break; |
| 332 | | | |
| 333 | | | if (i > 0) |
| 334 | | | str_append(str, ", "); |
| 335 | | | str_printfa(str, "%u", lines[i]); |
| 336 | | | } |
| 337 | | | |
| 338 | | | if (i == 1 && size > 0 && |
| 339 | | | ((const char *)data)[size-1] == '\n') |
| 340 | | | size--; |
| 341 | | | if (size > 0) |
| 342 | | | str_printfa(str, ": %.*s", (int)size, (const char *)data); |
| 343 | | | break; |
| 344 | | | } |
| 345 | | | case MAIL_CACHE_FIELD_COUNT: |
| 346 | | | i_unreached();
x /home/sate/Testcases/c/cve/dovecot-1.2.0/src/lib/macros.h |
| |
208 | #define i_unreached() \ |
209 | i_panic("file %s: line %d: unreached", __FILE__, __LINE__) |
| |
|
| 347 | | | break; |
Unreachable Control Flow
The highlighted code will not execute under any circumstances. |
|
| 348 | | | } |
| 349 | | | |
| 350 | | | printf("%s\n", str_c(str)); |
| 351 | | | } |
| 352 | | | if (ret < 0) |
| 353 | | | printf(" - broken cache\n"); |
| 354 | | | } |
| |