(/home/sate/Testcases/c/cve/dovecot-1.2.0/src/lib-storage/index/index-storage.c) |
| |
| 70 | | | static int create_index_dir(struct mail_storage *storage, const char *name) |
| 71 | | | { |
| 72 | | | const char *root_dir, *index_dir, *p, *parent_dir; |
| 73 | | | const char *origin, *parent_origin; |
| 74 | | | mode_t mode, parent_mode; |
| 75 | | | gid_t gid, parent_gid; |
| 76 | | | int n = 0; |
| 77 | | | |
| 78 | | | root_dir = mailbox_list_get_path(storage->list, name, |
| 79 | | | MAILBOX_LIST_PATH_TYPE_MAILBOX); |
| 80 | | | index_dir = mailbox_list_get_path(storage->list, name, |
Event 2:
index_dir is set to mailbox_list_get_path(...), which evaluates to list->v.get_path(...) from mailbox-list.c:446. See related event 1.
hide
|
|
| 81 | [+] | | MAILBOX_LIST_PATH_TYPE_INDEX); |
 |
| 82 | | | if (strcmp(index_dir, root_dir) == 0 || *index_dir == '\0') |
Event 3:
Skipping " if". - strcmp(...) == 0 evaluates to false.
- *index_dir == 0 evaluates to false.
hide
|
|
| 83 | | | return 0; |
| 84 | | | |
| 85 | | | mailbox_list_get_dir_permissions(storage->list, name, |
| 86 | | | &mode, &gid, &origin); |
| 87 | [+] | | while (mkdir_chgrp(index_dir, mode, gid, origin) < 0) { |
Event 5:
During loop iterations, the file named index_dir is accessed, where index_dir is list->v.get_path(...) from mailbox-list.c:446. - The same name is used to access a file later, but it is not safe to assume that it will be the same underlying file.
See related event 2.
hide
Event 6:
index_dir, which evaluates to list->v.get_path(...) from mailbox-list.c:446, is passed to mkdir_chgrp() as the first argument. See related event 2.
hide
|
|
 |
| 88 | | | if (errno == EEXIST) |
| 89 | | | break; |
| 90 | | | |
| 91 | | | p = strrchr(index_dir, '/'); |
| 92 | | | if (errno != ENOENT || p == NULL || ++n == 2) {
x /usr/include/asm-generic/errno-base.h |
| |
5 | #define ENOENT 2 /* No such file or directory */ |
| |
|
| 93 | | | mail_storage_set_critical(storage, |
| 94 | | | "mkdir(%s) failed: %m", index_dir); |
| 95 | | | return -1; |
| 96 | | | } |
| 97 | | | |
| 98 | | | mailbox_list_get_dir_permissions(storage->list, NULL, |
| 99 | | | &parent_mode, &parent_gid, |
| 100 | | | &parent_origin); |
| 101 | | | parent_dir = t_strdup_until(index_dir, p); |
| 102 | | | if (mkdir_parents_chgrp(parent_dir, parent_mode, |
| 103 | | | parent_gid, parent_origin) < 0 && |
| 104 | | | errno != EEXIST) { |
| |