(/home/sate/Testcases/c/cve/dovecot-1.2.0/src/lib-storage/index/index-mail.c) |
| |
| 943 | | | int index_mail_get_special(struct mail *_mail, |
| 944 | | | enum mail_fetch_field field, const char **value_r) |
| 945 | | | { |
| 946 | | | struct index_mail *mail = (struct index_mail *)_mail; |
| 947 | | | struct index_mail_data *data = &mail->data; |
| 948 | | | struct mail_cache_field *cache_fields = mail->ibox->cache_fields; |
| 949 | | | string_t *str; |
| 950 | | | const void *ext_data; |
| 951 | | | |
| 952 | | | switch (field) { |
| 953 | | | case MAIL_FETCH_IMAP_BODY: { |
| 954 | | | unsigned int body_cache_field = |
| 955 | | | cache_fields[MAIL_CACHE_IMAP_BODY].idx; |
| 956 | | | unsigned int bodystructure_cache_field = |
| 957 | | | cache_fields[MAIL_CACHE_IMAP_BODYSTRUCTURE].idx; |
| 958 | | | |
| 959 | | | if (data->body != NULL) { |
| 960 | | | *value_r = data->body; |
| 961 | | | return 0; |
| 962 | | | } |
| 963 | | | |
| 964 | | | |
| 965 | | | |
| 966 | | | |
| 967 | | | |
| 968 | | | |
| 969 | | | |
| 970 | | | str = str_new(mail->data_pool, 128); |
| 971 | | | if ((mail->data.cache_flags & |
| 972 | | | MAIL_CACHE_FLAG_TEXT_PLAIN_7BIT_ASCII) != 0 && |
| 973 | | | get_cached_parts(mail)) { |
| 974 | | | index_mail_get_plain_bodystructure(mail, str, FALSE); |
| 975 | | | data->body = str_c(str); |
| 976 | | | } else if (index_mail_cache_lookup_field(mail, str, |
| 977 | | | body_cache_field) > 0) |
| 978 | | | data->body = str_c(str); |
| 979 | | | else if (index_mail_cache_lookup_field(mail, str, |
| 980 | | | bodystructure_cache_field) > 0) { |
| 981 | | | data->bodystructure = |
| 982 | | | p_strdup(mail->data_pool, str_c(str)); |
| 983 | | | str_truncate(str, 0); |
| 984 | | | |
| 985 | | | if (imap_body_parse_from_bodystructure( |
| 986 | | | data->bodystructure, str)) |
| 987 | | | data->body = str_c(str); |
| 988 | | | else { |
| 989 | | | |
| 990 | | | mail_set_cache_corrupted(_mail, |
| 991 | | | MAIL_FETCH_IMAP_BODYSTRUCTURE); |
| 992 | | | } |
| 993 | | | } |
| 994 | | | |
| 995 | | | if (data->body == NULL) { |
| 996 | | | str_free(&str); |
| 997 | | | if (index_mail_parse_bodystructure(mail, |
| 998 | | | MAIL_CACHE_IMAP_BODY) < 0) |
| 999 | | | return -1; |
| 1000 | | | } |
| 1001 | | | i_assert(data->body != NULL);
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 |
| |
|
| 1002 | | | *value_r = data->body; |
| 1003 | | | return 0; |
| 1004 | | | } |
| 1005 | | | case MAIL_FETCH_IMAP_BODYSTRUCTURE: { |
| 1006 | | | unsigned int bodystructure_cache_field = |
| 1007 | | | cache_fields[MAIL_CACHE_IMAP_BODYSTRUCTURE].idx; |
| 1008 | | | |
| 1009 | | | if (data->bodystructure != NULL) { |
| 1010 | | | *value_r = data->bodystructure; |
| 1011 | | | return 0; |
| 1012 | | | } |
| 1013 | | | |
| 1014 | | | str = str_new(mail->data_pool, 128); |
| 1015 | | | if ((mail->data.cache_flags & |
| 1016 | | | MAIL_CACHE_FLAG_TEXT_PLAIN_7BIT_ASCII) != 0 && |
| 1017 | | | get_cached_parts(mail)) { |
| 1018 | | | index_mail_get_plain_bodystructure(mail, str, TRUE); |
| 1019 | | | data->bodystructure = str_c(str); |
| 1020 | | | } else if (index_mail_cache_lookup_field(mail, str, |
| 1021 | | | bodystructure_cache_field) > 0) { |
| 1022 | | | data->bodystructure = str_c(str); |
| 1023 | | | } else { |
| 1024 | | | str_free(&str); |
| 1025 | | | if (index_mail_parse_bodystructure(mail, |
| 1026 | | | MAIL_CACHE_IMAP_BODYSTRUCTURE) < 0) |
| 1027 | | | return -1; |
| 1028 | | | } |
| 1029 | | | i_assert(data->bodystructure != NULL);
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 |
| |
|
| 1030 | | | *value_r = data->bodystructure; |
| 1031 | | | return 0; |
| 1032 | | | } |
| 1033 | | | case MAIL_FETCH_IMAP_ENVELOPE: |
| 1034 | | | if (data->envelope == NULL) { |
| 1035 | | | if ((mail) < 0) |
| 1036 | | | return -1; |
| 1037 | | | } |
| 1038 | | | *value_r = data->envelope; |
| 1039 | | | return 0; |
| 1040 | | | case MAIL_FETCH_FROM_ENVELOPE: |
| 1041 | | | case MAIL_FETCH_UIDL_FILE_NAME: |
| 1042 | | | case MAIL_FETCH_UIDL_BACKEND: |
| 1043 | | | case MAIL_FETCH_SEARCH_SCORE: |
| 1044 | | | case MAIL_FETCH_GUID: |
| 1045 | | | *value_r = ""; |
| 1046 | | | return 0; |
| 1047 | | | case : |
| 1048 | | | mail_index_lookup_ext(mail->trans->trans_view, data->seq, |
| 1049 | | | mail->ibox->md5hdr_ext_idx, |
| 1050 | | | &ext_data, NULL); |
| 1051 | | | if (ext_data == NULL) { |
| 1052 | | | *value_r = ""; |
| 1053 | | | return 0; |
| 1054 | | | } |
| 1055 | | | *value_r = binary_to_hex(ext_data, 16); |
| 1056 | | | return 0; |
| 1057 | | | case MAIL_FETCH_MAILBOX_NAME: |
| 1058 | | | *value_r = _mail->box->name; |
| 1059 | | | return 0; |
| 1060 | | | default: |
| 1061 | | | 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__) |
| |
|
| 1062 | | | return -1; |
Unreachable Computation
The highlighted code will not execute under any circumstances. |
|
| 1063 | | | } |
| 1064 | | | } |
| |