(/home/sate/Testcases/c/cve/dovecot-1.2.0/src/lib-storage/index/maildir/maildir-sync.c) |
| |
| 276 | | | static int maildir_fix_duplicate(struct maildir_sync_context *ctx, |
| 277 | | | const char *dir, const char *fname2) |
| 278 | | | { |
| 279 | | | const char *fname1, *path1, *path2; |
| 280 | | | const char *new_fname, *new_path; |
| 281 | | | struct stat st1, st2; |
| 282 | | | |
| 283 | | | fname1 = maildir_uidlist_sync_get_full_filename(ctx->uidlist_sync_ctx, |
| 284 | | | fname2); |
| 285 | | | i_assert(fname1 != 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 |
| |
|
| 286 | | | |
| 287 | | | path1 = t_strconcat(dir, "/", fname1, NULL); |
| 288 | | | path2 = t_strconcat(dir, "/", fname2, NULL); |
Ignored Return Value
The return value of t_strconcat() is never checked in the highlighted execution scenario. - If the return value can indicate an error, the error will be ignored if the highlighted code executes.
- The return value of t_strconcat() is checked 98% of the time in this project. CodeSonar is configured to enforce Ignored Return Value checks for any function whose return value is checked at least 96% of the time, unless the function is used fewer than 20 times. (To modify these thresholds, use configuration file parameters RETURN_CHECKER_SAMPLE_SIZE and RETURN_CHECKER_RATIO. To exempt t_strconcat() from the Ignored Return Value check, use configuration file parameter RETURN_CHECKER_IGNORED_FUNCS).
Show: All events | Only primary events |
|
| 289 | | | |
| 290 | | | if (stat(path1, &st1) < 0 || stat(path2, &st2) < 0) { |
Event 2:
Taking true branch. stat(path1, &st1) < 0 evaluates to true.
hide
|
|
| 291 | | | |
| 292 | | | |
| 293 | | | return 0; |
| 294 | | | } |
| 295 | | | if (st1.st_ino == st2.st_ino && |
| 296 | | | CMP_DEV_T(st1.st_dev, st2.st_dev)) {
x /home/sate/Testcases/c/cve/dovecot-1.2.0/src/lib/compat.h |
| |
59 | # define CMP_DEV_T(a, b) (major(a) == major(b) && minor(a) == minor(b)) |
| |
x /usr/include/sys/sysmacros.h |
| |
65 | # define major(dev) gnu_dev_major (dev) |
| |
x /usr/include/sys/sysmacros.h |
| |
65 | # define major(dev) gnu_dev_major (dev) |
| |
x /usr/include/sys/sysmacros.h |
| |
66 | # define minor(dev) gnu_dev_minor (dev) |
| |
x /usr/include/sys/sysmacros.h |
| |
66 | # define minor(dev) gnu_dev_minor (dev) |
| |
|
| 297 | | | |
| 298 | | | |
| 299 | | | if (st1.st_nlink > 1 && st2.st_nlink == st1.st_nlink && |
| 300 | | | st1.st_ctime == st2.st_ctime &&
x /usr/include/bits/stat.h |
| |
96 | # define st_ctime st_ctim.tv_sec |
| |
x /usr/include/bits/stat.h |
| |
96 | # define st_ctime st_ctim.tv_sec |
| |
|
| 301 | | | st1.st_ctime < ioloop_time - DUPE_LINKS_DELETE_SECS) {
x /usr/include/bits/stat.h |
| |
96 | # define st_ctime st_ctim.tv_sec |
| |
|
| 302 | | | |
| 303 | | | |
| 304 | | | |
| 305 | | | |
| 306 | | | |
| 307 | | | |
| 308 | | | |
| 309 | | | |
| 310 | | | |
| 311 | | | |
| 312 | | | if (unlink(path2) == 0) |
| 313 | | | i_warning("Unlinked a duplicate: %s", path2); |
| 314 | | | else { |
| 315 | | | mail_storage_set_critical( |
| 316 | | | &ctx->mbox->storage->storage, |
| 317 | | | "unlink(%s) failed: %m", path2); |
| 318 | | | } |
| 319 | | | } |
| 320 | | | return 0; |
| 321 | | | } |
| 322 | | | |
| 323 | | | new_fname = maildir_filename_generate(); |
| 324 | | | new_path = t_strconcat(ctx->mbox->path, "/new/", new_fname, NULL); |
| 325 | | | |
| 326 | | | if (rename(path2, new_path) == 0) |
| 327 | | | i_warning("Fixed a duplicate: %s -> %s", path2, new_fname); |
| 328 | | | else if (errno != ENOENT) {
x /usr/include/asm-generic/errno-base.h |
| |
5 | #define ENOENT 2 /* No such file or directory */ |
| |
|
| 329 | | | mail_storage_set_critical(&ctx->mbox->storage->storage, |
| 330 | | | "Couldn't fix a duplicate: rename(%s, %s) failed: %m", |
| 331 | | | path2, new_path); |
| 332 | | | return -1; |
| 333 | | | } |
| 334 | | | return 0; |
| 335 | | | } |
| |