(/home/sate/Testcases/c/cve/dovecot-1.2.0/src/lib-index/mail-cache-transaction.c) |
| |
| 260 | | | static bool mail_cache_unlink_hole(struct mail_cache *cache, size_t size, |
| 261 | | | struct *hole_r) |
| 262 | | | { |
| 263 | | | struct *hdr = &cache->hdr_copy; |
| 264 | | | struct hole; |
| 265 | | | uint32_t offset, prev_offset; |
| 266 | | | |
| 267 | | | i_assert(cache->locked);
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 |
| |
|
| 268 | | | |
| 269 | | | offset = hdr->hole_offset; prev_offset = 0; |
| 270 | | | while (offset != 0) { |
| 271 | | | if (pread_full(cache->fd, &hole, sizeof(hole), offset) <= 0) { |
| 272 | | | mail_cache_set_syscall_error(cache, "pread_full()"); |
| 273 | | | return FALSE; |
| 274 | | | } |
| 275 | | | |
| 276 | | | if (hole.magic != ) { |
| 277 | | | mail_cache_set_corrupted(cache, |
| 278 | | | "Invalid magic in hole "); |
| 279 | | | return FALSE; |
| 280 | | | } |
| 281 | | | |
| 282 | | | if (hole.size >= size) |
| 283 | | | break; |
| 284 | | | |
| 285 | | | prev_offset = offset; |
| 286 | | | offset = hole.next_offset; |
| 287 | | | } |
| 288 | | | if (offset == 0) |
| 289 | | | return FALSE; |
| 290 | | | |
| 291 | | | if (prev_offset == 0) |
Redundant Condition
prev_offset == 0 always evaluates to true. 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 prev_offset == 0 cannot be false.
- A crashing bug occurs on every path where prev_offset == 0 could have evaluated to false. Look for a preceding Null Pointer Dereference or Division By Zero warning.
|
|
| 292 | | | hdr->hole_offset = hole.next_offset; |
| 293 | | | else { |
| 294 | | | if (mail_cache_write(cache, &hole.next_offset, |
| 295 | | | sizeof(hole.next_offset), prev_offset) < 0) |
| 296 | | | return FALSE; |
| 297 | | | } |
| 298 | | | hdr->deleted_space -= hole.size; |
| 299 | | | cache->hdr_modified = TRUE; |
| 300 | | | |
| 301 | | | hole_r->next_offset = offset; |
| 302 | | | hole_r->size = hole.size; |
| 303 | | | return TRUE; |
| 304 | | | } |
| |