(/home/sate/Testcases/c/cve/dovecot-1.2.0/src/lib-storage/list/mailbox-list-maildir-iter.c) |
| |
| 119 | | | maildir_fill_readdir(struct maildir_list_iterate_context *ctx, |
| 120 | | | struct imap_match_glob *glob, bool update_only) |
| 121 | | | { |
| 122 | | | struct mail_namespace *ns = ctx->ctx.list->ns; |
| 123 | | | DIR *dirp; |
| 124 | | | struct dirent *d; |
| 125 | | | const char *mailbox_name; |
| 126 | | | string_t *mailbox; |
| 127 | | | enum mailbox_info_flags flags; |
| 128 | | | enum imap_match_result match; |
| 129 | | | struct mailbox_node *node; |
| 130 | | | bool created, virtual_names; |
| 131 | | | char prefix_char; |
| 132 | | | int ret; |
| 133 | | | |
| 134 | | | dirp = opendir(ctx->dir); |
| 135 | | | if (dirp == NULL) { |
| 136 | | | if (errno == EACCES) {
x /usr/include/asm-generic/errno-base.h |
| |
16 | #define EACCES 13 /* Permission denied */ |
| |
|
| 137 | | | mailbox_list_set_critical(ctx->ctx.list, "%s", |
| 138 | | | mail_error_eacces_msg("opendir", ctx->dir)); |
| 139 | | | } else if (errno != ENOENT) {
x /usr/include/asm-generic/errno-base.h |
| |
5 | #define ENOENT 2 /* No such file or directory */ |
| |
|
| 140 | | | mailbox_list_set_critical(ctx->ctx.list, |
| 141 | | | "opendir(%s) failed: %m", ctx->dir); |
| 142 | | | return -1; |
| 143 | | | } |
| 144 | | | return 0; |
| 145 | | | } |
| 146 | | | |
| 147 | | | virtual_names = (ctx->ctx.flags & MAILBOX_LIST_ITER_VIRTUAL_NAMES) != 0; |
| 148 | | | prefix_char = |
| 149 | | | strcmp(ctx->ctx.list->name, MAILBOX_LIST_NAME_IMAPDIR) != 0 ? |
| 150 | | | ctx->ctx.list->hierarchy_sep : '\0'; |
| 151 | | | |
| 152 | | | mailbox = t_str_new(PATH_MAX);
x /usr/include/linux/limits.h |
| |
12 | #define PATH_MAX 4096 /* # chars in a path name including nul */ |
| |
|
| 153 | | | while ((d = readdir(dirp)) != NULL) { |
| 154 | | | const char *fname = d->d_name; |
| 155 | | | |
| 156 | | | if (fname[0] == prefix_char) |
| 157 | | | mailbox_name = fname + 1; |
| 158 | | | else { |
| 159 | | | if (prefix_char != '\0' || fname[0] == '.') |
| 160 | | | continue; |
| 161 | | | mailbox_name = fname; |
| 162 | | | } |
| 163 | | | |
| 164 | | | |
| 165 | | | if (fname[0] == '.' && |
| 166 | | | (fname[1] == '\0' || (fname[1] == '.' && fname[2] == '\0'))) |
| 167 | | | continue; |
| 168 | | | |
| 169 | | | if (!virtual_names) { |
| 170 | | | str_truncate(mailbox, 0); |
| 171 | | | str_append(mailbox, mailbox_name); |
| 172 | | | mailbox_name = str_c(mailbox); |
| 173 | | | } else { |
| 174 | | | mailbox_name = mail_namespace_get_vname(ns, mailbox, |
| 175 | | | mailbox_name); |
| 176 | | | } |
| 177 | | | |
| 178 | | | |
| 179 | | | match = imap_match(glob, mailbox_name); |
| 180 | | | if ((match & (IMAP_MATCH_YES | IMAP_MATCH_PARENT)) == 0) |
| 181 | | | continue; |
| 182 | | | |
| 183 | | | |
| 184 | | | flags = 0; |
| 185 | | | T_BEGIN {
x /home/sate/Testcases/c/cve/dovecot-1.2.0/src/lib/data-stack.h |
| |
49 | #define T_BEGIN \ |
50 | STMT_START { unsigned int _data_stack_cur_id = t_push(); |
| |
|
| 186 | | | ret = ctx->ctx.list->v. |
| 187 | | | iter_is_mailbox(&ctx->ctx, ctx->dir, fname, |
| 188 | | | mailbox_name, |
| 189 | | | mailbox_list_get_file_type(d), &flags); |
| 190 | | | } T_END; |
| 191 | | | if (ret <= 0) { |
| 192 | | | if (ret < 0) |
| 193 | | | return -1; |
| 194 | | | continue; |
| 195 | | | } |
| 196 | | | |
| 197 | | | |
| 198 | | | |
| 199 | | | flags &= ~(MAILBOX_NOINFERIORS | |
| 200 | | | MAILBOX_CHILDREN | MAILBOX_NOCHILDREN); |
| 201 | | | |
| 202 | | | if ((match & IMAP_MATCH_PARENT) != 0) { |
| 203 | | | T_BEGIN {
x /home/sate/Testcases/c/cve/dovecot-1.2.0/src/lib/data-stack.h |
| |
49 | #define T_BEGIN \ |
50 | STMT_START { unsigned int _data_stack_cur_id = t_push(); |
| |
|
| 204 | | | maildir_fill_parents(ctx, glob, update_only, |
| 205 | | | mailbox, flags); |
| 206 | | | } T_END; |
| 207 | | | } else { |
| 208 | | | created = FALSE; |
| 209 | | | node = update_only ? |
| 210 | | | mailbox_tree_lookup(ctx->tree_ctx, |
| 211 | | | mailbox_name) : |
| 212 | | | mailbox_tree_get(ctx->tree_ctx, |
| 213 | | | mailbox_name, &created); |
| 214 | | | |
| 215 | | | if (node != NULL) { |
| 216 | | | if (created) |
| 217 | | | node->flags = MAILBOX_NOCHILDREN; |
| 218 | | | else |
| 219 | | | node->flags &= ~MAILBOX_NONEXISTENT; |
| 220 | | | if (!update_only) |
| 221 | | | node->flags |= MAILBOX_MATCHED; |
| 222 | | | node->flags |= flags; |
| 223 | | | node_fix_parents(node); |
| 224 | | | } else { |
| 225 | | | i_assert(update_only);
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 |
| |
|
| 226 | | | maildir_set_children(ctx, mailbox); |
| 227 | | | } |
| 228 | | | } |
| 229 | | | } |
| 230 | | | |
| 231 | | | if (closedir(dirp) < 0) { |
| 232 | | | mailbox_list_set_critical(ctx->ctx.list, |
| 233 | | | "readdir(%s) failed: %m", ctx->dir); |
| 234 | | | return -1; |
| 235 | | | } |
| 236 | | | |
| 237 | | | if ((ns->flags & NAMESPACE_FLAG_INBOX) != 0) { |
| 238 | | | |
| 239 | | | if (!virtual_names) |
| 240 | | | mailbox_name = "INBOX"; |
| 241 | | | else { |
| 242 | | | mailbox_name = mail_namespace_get_vname(ns, mailbox, |
Unreachable Data Flow
The highlighted code will not execute under any circumstances. This may be because of: |
|
| 243 | | | "INBOX"); |
| 244 | | | } |
| 245 | | | |
| 246 | | | created = FALSE; |
| 247 | | | node = update_only ? |
| 248 | | | mailbox_tree_lookup(ctx->tree_ctx, mailbox_name) : |
| 249 | | | mailbox_tree_get(ctx->tree_ctx, mailbox_name, &created); |
| 250 | | | if (created) |
| 251 | | | node->flags = MAILBOX_NOCHILDREN; |
| 252 | | | else if (node != NULL) |
| 253 | | | node->flags &= ~MAILBOX_NONEXISTENT; |
| 254 | | | |
| 255 | | | match = imap_match(glob, mailbox_name); |
| 256 | | | if ((match & (IMAP_MATCH_YES | IMAP_MATCH_PARENT)) != 0) { |
| 257 | | | if (!update_only) |
| 258 | | | node->flags |= MAILBOX_MATCHED; |
| 259 | | | } |
| 260 | | | } |
| 261 | | | return 0; |
| 262 | | | } |
| |