(/home/sate/Testcases/c/cve/dovecot-1.2.0/src/lib-index/mail-transaction-log-file.c) |
| |
| 381 | | | mail_transaction_log_file_read_hdr(struct mail_transaction_log_file *file, |
| 382 | | | bool ignore_estale) |
| 383 | | | { |
| 384 | | | struct mail_transaction_log_file *f; |
| 385 | | | int ret; |
| 386 | | | |
| 387 | | | i_assert(!MAIL_TRANSACTION_LOG_FILE_IN_MEMORY(file));
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 |
| |
|
| 388 | | | |
| 389 | | | if (file->corrupted) |
| 390 | | | return 0; |
| 391 | | | |
| 392 | | | ret = (file); |
| 393 | | | if (ret < 0) { |
| 394 | | | if (errno != ESTALE || !ignore_estale) {
x /usr/include/asm-generic/errno.h |
| |
89 | #define ESTALE 116 /* Stale NFS file handle */ |
| |
|
| 395 | | | mail_index_file_set_syscall_error(file->log->index, |
| 396 | | | file->filepath, |
| 397 | | | "pread()"); |
| 398 | | | } |
| 399 | | | return -1; |
| 400 | | | } |
| 401 | | | if (file->hdr.major_version != MAIL_TRANSACTION_LOG_MAJOR_VERSION) { |
| 402 | | | |
| 403 | | | return 0; |
| 404 | | | } |
| 405 | | | if (ret < ) { |
| 406 | | | mail_transaction_log_file_set_corrupted(file, |
| 407 | | | "unexpected end of file while reading "); |
| 408 | | | return 0; |
| 409 | | | } |
| 410 | | | |
| 411 | | | if (file->hdr.minor_version >= 2 || file->hdr.major_version > 1) { |
Redundant Condition
file->hdr.major_version > 1 always evaluates to false. This may be because: - There is a constant assignment to one or more of the variables involved.
- An earlier conditional statement has already ensured that file->hdr.major_version > 1 cannot be true.
- A crashing bug occurs on every path where file->hdr.major_version > 1 could have evaluated to true. Look for a preceding Null Pointer Dereference or Division By Zero warning.
|
|
| 412 | | | |
| 413 | | | enum compat_flags = 0; |
| 414 | | | |
| 415 | | | #ifndef WORDS_BIGENDIAN |
| 416 | | | compat_flags |= MAIL_INDEX_COMPAT_LITTLE_ENDIAN; |
| 417 | | | #endif |
| 418 | | | if (file->hdr.compat_flags != compat_flags) { |
| 419 | | | |
| 420 | | | mail_index_set_error(file->log->index, |
| 421 | | | "Rebuilding index file %s: " |
| 422 | | | "CPU architecture changed", |
| 423 | | | file->log->index->filepath); |
| 424 | | | return 0; |
| 425 | | | } |
| 426 | | | } |
| 427 | | | if (file->hdr.hdr_size < ) { |
| 428 | | | mail_transaction_log_file_set_corrupted(file, |
| 429 | | | " size too small"); |
| 430 | | | return 0; |
| 431 | | | } |
| 432 | | | if (file->hdr.hdr_size < sizeof(file->hdr)) { |
| 433 | | | |
| 434 | | | |
| 435 | | | memset(PTR_OFFSET(&file->hdr, file->hdr.hdr_size), 0,
x /home/sate/Testcases/c/cve/dovecot-1.2.0/src/lib/macros.h |
| |
27 | #define PTR_OFFSET(ptr, offset) \ |
28 | ((void *) (((unsigned char *) (ptr)) + (offset))) |
| |
|
| 436 | | | sizeof(file->hdr) - file->hdr.hdr_size); |
| 437 | | | } |
| 438 | | | |
| 439 | | | if (file->hdr.indexid == 0) { |
| 440 | | | |
| 441 | | | file->corrupted = TRUE; |
| 442 | | | mail_index_set_error(file->log->index, |
| 443 | | | "Transaction log file %s: marked corrupted", |
| 444 | | | file->filepath); |
| 445 | | | return 0; |
| 446 | | | } |
| 447 | | | if (file->hdr.indexid != file->log->index->indexid) { |
| 448 | | | if (file->log->index->indexid != 0 && |
| 449 | | | !file->log->index->initial_create) { |
| 450 | | | |
| 451 | | | |
| 452 | | | mail_transaction_log_file_set_corrupted(file, |
| 453 | | | "indexid changed %u -> %u", |
| 454 | | | file->log->index->indexid, file->hdr.indexid); |
| 455 | | | return 0; |
| 456 | | | } |
| 457 | | | |
| 458 | | | |
| 459 | | | |
| 460 | | | |
| 461 | | | file->log->index->indexid = file->hdr.indexid; |
| 462 | | | } |
| 463 | | | |
| 464 | | | |
| 465 | | | |
| 466 | | | |
| 467 | | | for (f = file->log->files; f != NULL; f = f->next) { |
| 468 | | | if (f->hdr.file_seq == file->hdr.file_seq) { |
| 469 | | | |
| 470 | | | |
| 471 | | | mail_transaction_log_file_set_corrupted(f, |
| 472 | | | "duplicate transaction log sequence (%u)", |
| 473 | | | f->hdr.file_seq); |
| 474 | | | return 0; |
| 475 | | | } |
| 476 | | | } |
| 477 | | | |
| 478 | | | file->sync_highest_modseq = file->hdr.initial_modseq; |
| 479 | | | return 1; |
| 480 | | | } |
| |