(/home/sate/Testcases/c/cve/dovecot-1.2.0/src/lib-index/mail-index-transaction.c) |
| |
| 490 | | | void mail_index_transaction_sort_appends(struct mail_index_transaction *t) |
| 491 | | | { |
| 492 | | | struct mail_index_record *recs, *sorted_recs; |
| 493 | | | struct uid_map *new_uid_map; |
| 494 | | | uint32_t *old_to_newseq_map; |
| 495 | | | unsigned int i, count; |
| 496 | | | |
| 497 | | | if (!t->appends_nonsorted) |
| 498 | | | return; |
| 499 | | | |
| 500 | | | |
| 501 | | | recs = array_get_modifiable(&t->appends, &count);
x /home/sate/Testcases/c/cve/dovecot-1.2.0/src/lib/array.h |
| |
174 | #define array_get_modifiable(array, count) \ |
175 | ARRAY_TYPE_CAST_MODIFIABLE(array) \ |
176 | array_get_modifiable_i(&(array)->arr, count) |
| |
x /home/sate/Testcases/c/cve/dovecot-1.2.0/src/lib/array.h |
| |
45 | # define ARRAY_TYPE_CAST_MODIFIABLE(array) \ |
46 | (typeof(*(array)->v_modifiable)) |
| |
|
| 502 | | | i_assert(count > 0);
x /home/sate/Testcases/c/cve/dovecot-1.2.0/src/lib/macros.h |
| |
189 | #define i_assert(expr) STMT_START{ \ |
190 | if (unlikely(!(expr))) \ |
191 | i_panic("file %s: line %d (%s): assertion failed: (%s)", \ |
192 | __FILE__, \ |
193 | __LINE__, \ |
194 | __PRETTY_FUNCTION__, \ |
195 | #expr); }STMT_END |
| |
|
| 503 | | | |
| 504 | | | new_uid_map = i_new(struct uid_map, count);
x /home/sate/Testcases/c/cve/dovecot-1.2.0/src/lib/imem.h |
| |
8 | #define i_new(type, count) ((type *) i_malloc(sizeof(type) * (count))) |
| |
|
| 505 | | | for (i = 0; i < count; i++) { |
| 506 | | | new_uid_map[i].idx = i; |
| 507 | | | new_uid_map[i].uid = recs[i].uid; |
| 508 | | | } |
| 509 | | | |
| 510 | | | |
| 511 | | | qsort(new_uid_map, count, sizeof(*new_uid_map), uid_map_cmp); |
| 512 | | | |
| 513 | | | |
| 514 | | | sorted_recs = i_new(struct mail_index_record, count);
x /home/sate/Testcases/c/cve/dovecot-1.2.0/src/lib/imem.h |
| |
8 | #define i_new(type, count) ((type *) i_malloc(sizeof(type) * (count))) |
| |
|
| 515 | | | sorted_recs[0] = recs[new_uid_map[0].idx]; |
| 516 | | | for (i = 1; i < count; i++) { |
| 517 | | | sorted_recs[i] = recs[new_uid_map[i].idx]; |
| 518 | | | if (sorted_recs[i].uid == sorted_recs[i-1].uid) |
| 519 | | | i_panic("Duplicate UIDs added in transaction"); |
| 520 | | | } |
| 521 | | | buffer_write(t->appends.arr.buffer, 0, sorted_recs, |
| 522 | | | sizeof(*sorted_recs) * count); |
| 523 | | | i_free(sorted_recs);
x /home/sate/Testcases/c/cve/dovecot-1.2.0/src/lib/imem.h |
| |
14 | #define i_free(mem) \ |
15 | STMT_START { \ |
16 | free(mem); \ |
17 | (mem) = NULL; \ |
18 | } STMT_END |
| |
|
Unreachable Call
The highlighted code will not execute under any circumstances. |
|
| 524 | | | |
| 525 | | | old_to_newseq_map = i_new(uint32_t, count);
x /home/sate/Testcases/c/cve/dovecot-1.2.0/src/lib/imem.h |
| |
8 | #define i_new(type, count) ((type *) i_malloc(sizeof(type) * (count))) |
| |
|
| 526 | | | for (i = 0; i < count; i++) |
| 527 | | | old_to_newseq_map[new_uid_map[i].idx] = i + t->first_new_seq; |
| 528 | | | i_free(new_uid_map);
x /home/sate/Testcases/c/cve/dovecot-1.2.0/src/lib/imem.h |
| |
14 | #define i_free(mem) \ |
15 | STMT_START { \ |
16 | free(mem); \ |
17 | (mem) = NULL; \ |
18 | } STMT_END |
| |
|
| 529 | | | |
| 530 | | | mail_index_transaction_sort_appends_ext(t, old_to_newseq_map); |
| 531 | | | mail_index_transaction_sort_appends_keywords(t, old_to_newseq_map); |
| 532 | | | i_free(old_to_newseq_map);
x /home/sate/Testcases/c/cve/dovecot-1.2.0/src/lib/imem.h |
| |
14 | #define i_free(mem) \ |
15 | STMT_START { \ |
16 | free(mem); \ |
17 | (mem) = NULL; \ |
18 | } STMT_END |
| |
|
| 533 | | | |
| 534 | | | t->appends_nonsorted = FALSE; |
| 535 | | | } |
| |