(/home/sate/Testcases/c/cve/dovecot-1.2.0/src/deliver/deliver.c) |
| |
| 208 | | | int deliver_save(struct mail_namespace *namespaces, |
| 209 | | | struct mail_storage **storage_r, const char *mailbox, |
| 210 | | | struct mail *mail, enum mail_flags flags, |
| 211 | | | const char *const *keywords) |
| 212 | | | { |
| 213 | | | struct mailbox *box; |
| 214 | | | struct mailbox_transaction_context *t; |
| 215 | | | struct mail_save_context *save_ctx; |
| 216 | | | struct mail_keywords *kw; |
| 217 | | | enum mail_error error; |
| 218 | | | const char *mailbox_name; |
| 219 | | | bool default_save; |
| 220 | | | int ret = 0; |
| 221 | | | |
| 222 | | | default_save = strcmp(mailbox, default_mailbox_name) == 0; |
| 223 | | | if (default_save) |
| 224 | | | tried_default_save = TRUE; |
| 225 | | | |
| 226 | | | mailbox_name = str_sanitize(mailbox, 80); |
Ignored Return Value
The return value of str_sanitize() 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 str_sanitize() is checked 97% 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 str_sanitize() from the Ignored Return Value check, use configuration file parameter RETURN_CHECKER_IGNORED_FUNCS).
Show: All events | Only primary events |
|
| 227 | | | box = mailbox_open_or_create_synced(namespaces, storage_r, mailbox); |
| 228 | | | if (box == NULL) { |
Event 2:
Taking true branch. box == (void *)0 evaluates to true.
hide
|
|
| 229 | | | if (*storage_r == NULL) { |
Event 3:
Skipping " if". *storage_r == (void *)0 evaluates to false.
hide
|
|
| 230 | | | deliver_log(mail, |
| 231 | | | "save failed to %s: Unknown namespace", |
| 232 | | | mailbox_name); |
| 233 | | | return -1; |
| 234 | | | } |
| 235 | | | if (default_save && |
| 236 | | | strcmp((*storage_r)->ns->prefix, mailbox) == 0) { |
| 237 | | | |
| 238 | | | return -1; |
| 239 | | | } |
| 240 | | | deliver_log(mail, "save failed to %s: %s", mailbox_name, |
| 241 | | | mail_storage_get_last_error(*storage_r, &error)); |
| 242 | | | return -1; |
| 243 | | | } |
| 244 | | | |
| 245 | | | t = mailbox_transaction_begin(box, MAILBOX_TRANSACTION_FLAG_EXTERNAL); |
| 246 | | | |
| 247 | | | kw = str_array_length(keywords) == 0 ? NULL : |
| 248 | | | mailbox_keywords_create_valid(box, keywords); |
| 249 | | | save_ctx = mailbox_save_alloc(t); |
| 250 | | | mailbox_save_set_flags(save_ctx, flags, kw); |
| 251 | | | if (mailbox_copy(&save_ctx, mail) < 0) |
| 252 | | | ret = -1; |
| 253 | | | mailbox_keywords_free(box, &kw); |
| 254 | | | |
| 255 | | | if (ret < 0) |
| 256 | | | mailbox_transaction_rollback(&t); |
| 257 | | | else |
| 258 | | | ret = mailbox_transaction_commit(&t); |
| 259 | | | |
| 260 | | | if (ret == 0) { |
| 261 | | | saved_mail = TRUE; |
| 262 | | | deliver_log(mail, "saved mail to %s", mailbox_name); |
| 263 | | | } else { |
| 264 | | | deliver_log(mail, "save failed to %s: %s", mailbox_name, |
| 265 | | | mail_storage_get_last_error(*storage_r, &error)); |
| 266 | | | } |
| 267 | | | |
| 268 | | | mailbox_close(&box); |
| 269 | | | return ret; |
| 270 | | | } |
| |