(/home/sate/Testcases/c/cve/dovecot-1.2.0/src/lib-storage/index/index-search.c) |
| |
| 210 | | | static int search_arg_match_cached(struct index_search_context *ctx, |
| 211 | | | struct mail_search_arg *arg) |
| 212 | | | { |
| 213 | | | const char *str; |
| 214 | | | struct tm *tm; |
| 215 | | | uoff_t virtual_size; |
| 216 | | | time_t date; |
| 217 | | | int timezone_offset; |
| 218 | | | |
| 219 | | | switch (arg->type) { |
| 220 | | | |
| 221 | | | case SEARCH_BEFORE: |
| 222 | | | case SEARCH_ON: |
| 223 | | | case SEARCH_SINCE: |
| 224 | | | if (mail_get_received_date(ctx->mail, &date) < 0) |
| 225 | | | return -1; |
| 226 | | | |
| 227 | | | if ((arg->value.search_flags & |
| 228 | | | MAIL_SEARCH_ARG_FLAG_USE_TZ) == 0) { |
| 229 | | | tm = localtime(&date); |
| 230 | | | date += utc_offset(tm, date)*60; |
| 231 | | | } |
| 232 | | | |
| 233 | | | switch (arg->type) { |
| 234 | | | case SEARCH_BEFORE: |
| 235 | | | return date < arg->value.time; |
| 236 | | | case SEARCH_ON: |
| 237 | | | return date >= arg->value.time && |
| 238 | | | date < arg->value.time + 3600*24; |
| 239 | | | case SEARCH_SINCE: |
| 240 | | | return date >= arg->value.time; |
| 241 | | | default: |
| 242 | | | |
| 243 | | | break; |
| 244 | | | } |
| 245 | | | |
| 246 | | | |
| 247 | | | case SEARCH_SENTBEFORE: |
| 248 | | | case SEARCH_SENTON: |
| 249 | | | case SEARCH_SENTSINCE: |
| 250 | | | |
| 251 | | | |
| 252 | | | if (mail_get_date(ctx->mail, &date, &timezone_offset) < 0) |
| 253 | | | return -1; |
| 254 | | | |
| 255 | | | if ((arg->value.search_flags & |
| 256 | | | MAIL_SEARCH_ARG_FLAG_USE_TZ) == 0) |
| 257 | | | date += timezone_offset * 60; |
| 258 | | | |
| 259 | | | switch (arg->type) { |
| 260 | | | case SEARCH_SENTBEFORE: |
| 261 | | | return date < arg->value.time; |
| 262 | | | case SEARCH_SENTON: |
| 263 | | | return date >= arg->value.time && |
| 264 | | | date < arg->value.time + 3600*24; |
| 265 | | | case SEARCH_SENTSINCE: |
| 266 | | | return date >= arg->value.time; |
| 267 | | | default: |
Unreachable Control Flow
The highlighted code will not execute under any circumstances. This may be because of: |
|
| 268 | | | |
| 269 | | | break; |
| 270 | | | } |
| 271 | | | |
| 272 | | | |
| 273 | | | case SEARCH_SMALLER: |
| 274 | | | case SEARCH_LARGER: |
| 275 | | | if (mail_get_virtual_size(ctx->mail, &virtual_size) < 0) |
| 276 | | | return -1; |
| 277 | | | |
| 278 | | | if (arg->type == SEARCH_SMALLER) |
| 279 | | | return virtual_size < arg->value.size; |
| 280 | | | else |
| 281 | | | return virtual_size > arg->value.size; |
| 282 | | | |
| 283 | | | case SEARCH_GUID: |
| 284 | | | if (mail_get_special(ctx->mail, MAIL_FETCH_GUID, &str) < 0) |
| 285 | | | return -1; |
| 286 | | | return strcmp(str, arg->value.str) == 0; |
| 287 | | | case SEARCH_MAILBOX: |
| 288 | | | if (mail_get_special(ctx->mail, MAIL_FETCH_MAILBOX_NAME, |
| 289 | | | &str) < 0) |
| 290 | | | return -1; |
| 291 | | | |
| 292 | | | if (strcasecmp(str, "INBOX") == 0) |
| 293 | | | return strcasecmp(arg->value.str, "INBOX") == 0; |
| 294 | | | return strcmp(str, arg->value.str) == 0; |
| 295 | | | default: |
| 296 | | | return -1; |
| 297 | | | } |
| 298 | | | } |
| |