(/home/sate/Testcases/c/cve/dovecot-1.2.0/src/lib-storage/index/mbox/mbox-sync-rewrite.c) |
| |
| 242 | | | int mbox_sync_try_rewrite(struct mbox_sync_mail_context *ctx, off_t move_diff) |
| 243 | | | { |
| 244 | | | struct mbox_sync_context *sync_ctx = ctx->sync_ctx; |
| 245 | | | size_t old_hdr_size, new_hdr_size; |
| 246 | | | |
| 247 | | | i_assert(sync_ctx->mbox->mbox_lock_type == F_WRLCK);
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 |
| |
x /usr/include/bits/fcntl.h |
| |
133 | #define F_WRLCK 1 /* Write lock. */ |
| |
|
| 248 | | | |
| 249 | | | old_hdr_size = ctx->body_offset - ctx->hdr_offset; |
| 250 | | | new_hdr_size = str_len(ctx->); |
| 251 | | | |
| 252 | | | if (new_hdr_size <= old_hdr_size) { |
| 253 | | | |
| 254 | | | |
| 255 | | | (ctx, old_hdr_size - new_hdr_size); |
| 256 | | | } else if (new_hdr_size > old_hdr_size) { |
Redundant Condition
new_hdr_size > old_hdr_size 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 new_hdr_size > old_hdr_size cannot be false.
- A crashing bug occurs on every path where new_hdr_size > old_hdr_size could have evaluated to false. Look for a preceding Null Pointer Dereference or Division By Zero warning.
|
|
| 257 | | | |
| 258 | | | (ctx, |
| 259 | | | new_hdr_size - old_hdr_size); |
| 260 | | | new_hdr_size = str_len(ctx->); |
| 261 | | | |
| 262 | | | if (new_hdr_size <= old_hdr_size) { |
| 263 | | | |
| 264 | | | i_assert(new_hdr_size == old_hdr_size);
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 |
| |
|
| 265 | | | } else if (move_diff < 0 && |
| 266 | | | new_hdr_size - old_hdr_size <= (uoff_t)-move_diff) { |
| 267 | | | |
| 268 | | | |
| 269 | | | i_assert(ctx->mail.space == 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 |
| |
|
| 270 | | | i_assert(sync_ctx->expunged_space >=
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 |
| |
|
| 271 | | | (off_t)(new_hdr_size - old_hdr_size)); |
| 272 | | | sync_ctx->expunged_space -= new_hdr_size - old_hdr_size; |
| 273 | | | } else { |
| 274 | | | |
| 275 | | | i_assert(ctx->mail.space == 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 |
| |
|
| 276 | | | ctx->mail.space = |
| 277 | | | -(ssize_t)(new_hdr_size - old_hdr_size); |
| 278 | | | return 0; |
| 279 | | | } |
| 280 | | | } |
| 281 | | | |
| 282 | | | i_assert(ctx->mail.space >= 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 |
| |
|
| 283 | | | |
| 284 | | | if (ctx-> == (size_t)-1 && move_diff == 0) { |
| 285 | | | |
| 286 | | | |
| 287 | | | return 1; |
| 288 | | | } |
| 289 | | | |
| 290 | | | if (move_diff != 0) { |
| 291 | | | |
| 292 | | | ctx-> = 0; |
| 293 | | | ctx-> = 0; |
| 294 | | | } |
| 295 | | | |
| 296 | | | if (ctx-> != (size_t)-1 && |
| 297 | | | ctx-> != 0) |
| 298 | | | str_truncate(ctx->, ctx->); |
| 299 | | | |
| 300 | | | if (pwrite_full(sync_ctx->write_fd, |
| 301 | | | str_data(ctx->) + ctx->, |
| 302 | | | str_len(ctx->) - ctx->, |
| 303 | | | ctx->hdr_offset + ctx-> + |
| 304 | | | move_diff) < 0) { |
| 305 | | | mbox_set_syscall_error(sync_ctx->mbox, "pwrite_full()"); |
| 306 | | | return -1; |
| 307 | | | } |
| 308 | | | |
| 309 | | | if (sync_ctx->dest_first_mail && |
| 310 | | | (ctx->imapbase_updated || ctx->sync_ctx->base_uid_last != 0)) { |
| 311 | | | |
| 312 | | | |
| 313 | | | mbox_sync_first_mail_written(ctx, ctx->hdr_offset + move_diff); |
| 314 | | | } |
| 315 | | | |
| 316 | | | mbox_sync_file_updated(sync_ctx, FALSE); |
| 317 | | | return 1; |
| 318 | | | } |
| |