From: Stephan Bosch Date: Fri, 4 Jul 2025 00:29:16 +0000 (+0200) Subject: lib-storage: mail-storage - Produce the error message in mailbox_name_check_forbidden... X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b734e7a603f4b484d21c83d02662c24e95d5d58c;p=thirdparty%2Fdovecot%2Fcore.git lib-storage: mail-storage - Produce the error message in mailbox_name_check_forbidden_chars() --- diff --git a/src/lib-storage/mail-storage.c b/src/lib-storage/mail-storage.c index edcee59efc..3127fe3140 100644 --- a/src/lib-storage/mail-storage.c +++ b/src/lib-storage/mail-storage.c @@ -1626,13 +1626,16 @@ static int mailbox_verify_existing_name(struct mailbox *box) return ret; } -static int mailbox_name_check_forbidden_chars(const char *name) +static int +mailbox_name_check_forbidden_chars(const char *name, const char **error_r) { const char *p; for (p = name; *p != '\0'; p++) { - if ((unsigned char)*p < ' ') + if ((unsigned char)*p < ' ') { + *error_r = "Control characters not allowed in new mailbox names"; return -1; + } } return 0; } @@ -1644,6 +1647,8 @@ void mailbox_skip_create_name_restrictions(struct mailbox *box, bool set) int mailbox_verify_create_name(struct mailbox *box) { + const char *error; + /* mailbox_alloc() already checks that vname is valid UTF8, so we don't need to verify that. @@ -1653,9 +1658,8 @@ int mailbox_verify_create_name(struct mailbox *box) return -1; if (box->skip_create_name_restrictions) return 0; - if (mailbox_name_check_forbidden_chars(box->vname) < 0) { - mail_storage_set_error(box->storage, MAIL_ERROR_PARAMS, - "Control characters not allowed in new mailbox names"); + if (mailbox_name_check_forbidden_chars(box->vname, &error) < 0) { + mail_storage_set_error(box->storage, MAIL_ERROR_PARAMS, error); return -1; } if (strlen(box->vname) > MAILBOX_LIST_NAME_MAX_LENGTH) {