(/home/sate/Testcases/c/cve/dovecot-1.2.0/src/lib-storage/index/shared/shared-storage.c) |
| |
| 125 | | | int shared_storage_get_namespace(struct mail_storage *_storage, |
| 126 | | | const char **_name, |
| 127 | | | struct mail_namespace **ns_r) |
| 128 | | | { |
| 129 | | | struct shared_storage *storage = (struct shared_storage *)_storage; |
| 130 | | | struct mail_user *user = _storage->ns->user; |
| 131 | | | static struct var_expand_table static_tab[] = { |
| 132 | | | { 'u', NULL, "user" }, |
| 133 | | | { 'n', NULL, "username" }, |
| 134 | | | { 'd', NULL, "domain" }, |
| 135 | | | { 'h', NULL, "home" }, |
| 136 | | | { '\0', NULL, NULL } |
| 137 | | | }; |
| 138 | | | struct var_expand_table *tab; |
| 139 | | | struct mail_namespace *ns; |
| 140 | | | struct mail_user *owner; |
| 141 | | | const char *domain = NULL, *username = NULL, *userdomain = NULL; |
| 142 | | | const char *name, *p, *next, **dest, *error; |
| 143 | | | string_t *prefix, *location; |
| 144 | | | int ret; |
| 145 | | | |
| 146 | | | *ns_r = NULL; |
| 147 | | | |
| 148 | | | p = storage->ns_prefix_pattern; |
| 149 | | | for (name = *_name; *p != '\0';) { |
Event 1:
The loop is executed one or more times.
hide
|
|
| 150 | | | if (*p != '%') { |
| 151 | | | if (*p != *name) |
| 152 | | | break; |
| 153 | | | p++; name++; |
| 154 | | | continue; |
| 155 | | | } |
| 156 | | | switch (*++p) { |
| 157 | | | case 'd': |
| 158 | | | dest = &domain; |
| 159 | | | break; |
| 160 | | | case 'n': |
| 161 | | | dest = &username; |
| 162 | | | break; |
| 163 | | | case 'u': |
| 164 | | | dest = &userdomain; |
| 165 | | | break; |
| 166 | | | default: |
| 167 | | | |
| 168 | | | i_unreached();
x /home/sate/Testcases/c/cve/dovecot-1.2.0/src/lib/macros.h |
| |
208 | #define i_unreached() \ |
209 | i_panic("file %s: line %d: unreached", __FILE__, __LINE__) |
| |
|
| 169 | | | } |
| 170 | | | p++; |
| 171 | | | |
| 172 | | | next = strchr(name, *p != '\0' ? *p : _storage->ns->sep); |
| 173 | | | if (next == NULL) { |
| 174 | | | *dest = name; |
| 175 | | | name = ""; |
| 176 | | | break; |
| 177 | | | } |
| 178 | | | *dest = t_strdup_until(name, next); |
| 179 | | | name = next; |
| 180 | | | } |
| 181 | | | if (*p != '\0') { |
Event 2:
Skipping " if". *p != 0 evaluates to false.
hide
|
|
| 182 | | | if (*name == '\0' || |
| 183 | | | (name[1] == '\0' && *name == _storage->ns->sep)) { |
| 184 | | | |
| 185 | | | name = "INBOX"; |
| 186 | | | } else { |
| 187 | | | mail_storage_set_critical(_storage, |
| 188 | | | "Invalid namespace prefix %s vs %s", |
| 189 | | | storage->ns_prefix_pattern, *_name); |
| 190 | | | return -1; |
| 191 | | | } |
| 192 | | | } |
| 193 | | | |
| 194 | | | |
| 195 | | | if (userdomain == NULL) { |
Event 3:
Taking true branch. userdomain == (void *)0 evaluates to true.
hide
|
|
| 196 | | | if (username == NULL) { |
Event 4:
Skipping " if". username == (void *)0 evaluates to false.
hide
|
|
| 197 | | | |
| 198 | | | |
| 199 | | | mail_storage_set_error(_storage, MAIL_ERROR_NOTFOUND, |
| 200 | | | T_MAIL_ERR_MAILBOX_NOT_FOUND(*_name));
x /home/sate/Testcases/c/cve/dovecot-1.2.0/src/lib-storage/mail-error.h |
| |
19 | #define T_MAIL_ERR_MAILBOX_NOT_FOUND(name) \ |
20 | t_strdup_printf(MAIL_ERRSTR_MAILBOX_NOT_FOUND, name) |
| |
|
| 201 | | | return -1; |
| 202 | | | } |
| 203 | | | userdomain = domain == NULL ? username : |
Event 5:
domain == (void *)0 evaluates to true.
hide
|
|
| 204 | | | t_strconcat(username, "@", domain, NULL); |
| 205 | | | } else { |
| 206 | | | domain = strchr(userdomain, '@'); |
| 207 | | | if (domain == NULL) |
| 208 | | | username = userdomain; |
| 209 | | | else { |
| 210 | | | username = t_strdup_until(userdomain, domain); |
| 211 | | | domain++; |
| 212 | | | } |
| 213 | | | } |
| 214 | | | if (*userdomain == '\0') { |
Event 6:
Skipping " if". *userdomain == 0 evaluates to false.
hide
|
|
| 215 | | | mail_storage_set_error(_storage, MAIL_ERROR_PARAMS, |
| 216 | | | "Empty username doesn't exist"); |
| 217 | | | return -1; |
| 218 | | | } |
| 219 | | | |
| 220 | | | |
| 221 | | | |
| 222 | | | tab = t_malloc(sizeof(static_tab)); |
| 223 | | | memcpy(tab, static_tab, sizeof(static_tab)); |
| 224 | | | tab[0].value = userdomain; |
| 225 | | | tab[1].value = username; |
| 226 | | | tab[2].value = domain; |
| 227 | | | |
| 228 | | | prefix = t_str_new(128); |
| 229 | | | str_append(prefix, _storage->ns->prefix); |
| 230 | | | var_expand(prefix, storage->ns_prefix_pattern, tab); |
| 231 | | | |
| 232 | [+] | | ns = mail_namespace_find_prefix(user->namespaces, str_c(prefix)); |
 |
| 233 | | | if (ns != NULL) { |
Event 8:
Skipping " if". ns != (void *)0 evaluates to false.
hide
|
|
| 234 | | | *_name = mail_namespace_fix_sep(ns, name); |
| 235 | | | *ns_r = ns; |
| 236 | | | return 0; |
| 237 | | | } |
| 238 | | | |
| 239 | | | owner = mail_user_init(userdomain); |
| 240 | | | if (!var_has_key(storage->location, 'h', "home")) |
Event 9:
Taking true branch. var_has_key(...) evaluates to false.
hide
|
|
| 241 | | | ret = 1; |
| 242 | | | else { |
| 243 | | | |
| 244 | | | if ((ret = mail_user_get_home(owner, &tab[3].value)) < 0) { |
| 245 | | | mail_storage_set_critical(_storage, "Namespace '%s': " |
| 246 | | | "Could not lookup home for user %s", |
| 247 | | | _storage->ns->prefix, userdomain); |
| 248 | | | mail_user_unref(&owner); |
| 249 | | | return -1; |
| 250 | | | } |
| 251 | | | } |
| 252 | | | |
| 253 | | | |
| 254 | | | ns = i_new(struct mail_namespace, 1);
x /home/sate/Testcases/c/cve/dovecot-1.2.0/src/lib/imem.h |
| |
8 | #define i_new(type, count) ((type *) i_malloc(sizeof(type) * (count))) |
| |
|
| 255 | | | ns->type = NAMESPACE_SHARED; |
| 256 | | | ns->user = user; |
| 257 | | | ns->prefix = i_strdup(str_c(prefix)); |
| 258 | | | ns->owner = owner; |
| 259 | | | ns->flags = (NAMESPACE_FLAG_SUBSCRIPTIONS & _storage->ns->flags) | |
| 260 | | | NAMESPACE_FLAG_LIST_PREFIX | NAMESPACE_FLAG_HIDDEN | |
| 261 | | | NAMESPACE_FLAG_AUTOCREATED | NAMESPACE_FLAG_INBOX; |
| 262 | | | ns->sep = _storage->ns->sep; |
| 263 | | | |
| 264 | | | location = t_str_new(256); |
| 265 | | | if (ret > 0) |
Event 10:
Taking true branch. ret > 0 evaluates to true.
hide
|
|
| 266 | | | var_expand(location, storage->location, tab); |
| 267 | | | else { |
| 268 | | | get_nonexisting_user_location(storage, userdomain, location); |
| 269 | | | ns->flags |= NAMESPACE_FLAG_UNUSABLE; |
| 270 | | | } |
| 271 | | | if (mail_storage_create(ns, NULL, str_c(location), _storage->flags, |
| 272 | [+] | | _storage->lock_method, &error) < 0) { |
Event 11:
&error is passed to mail_storage_create() as the sixth argument.
hide
Event 12:
mail_storage_create() does not initialize error. - This may be because of a failure case or other special case for mail_storage_create().
hide
|
|
 |
| |