]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-smtp: smtp_address_init_from_msg() - Avoid implicit char to unsigned char conversion
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Mon, 9 Nov 2020 16:10:21 +0000 (18:10 +0200)
committerTimo Sirainen <timo.sirainen@open-xchange.com>
Mon, 9 Nov 2020 16:10:21 +0000 (18:10 +0200)
Fixes calling smtp_char_is_qpair() with ubsan:
runtime error: implicit conversion from type 'char' of value -61 (8-bit, signed) to type 'unsigned char' changed the value to 195 (8-bit, unsigned)

src/lib-smtp/smtp-address.c

index 1997535d517c6de6928e014fe26f63731c106158..eac25e168c32709bb11eb5db41385e7af3b91f56 100644 (file)
@@ -762,7 +762,7 @@ void smtp_address_init(struct smtp_address *address,
 int smtp_address_init_from_msg(struct smtp_address *address,
                               const struct message_address *msg_addr)
 {
-       const char *p;
+       const unsigned char *p;
 
        i_zero(address);
        if (msg_addr->mailbox == NULL || *msg_addr->mailbox == '\0')
@@ -771,7 +771,7 @@ int smtp_address_init_from_msg(struct smtp_address *address,
        /* The message_address_parse() function allows UTF-8 codepoints in
           the localpart. For SMTP addresses that is not an option, so we
           need to check this upon conversion. */
-       for (p = msg_addr->mailbox; *p != '\0'; p++) {
+       for (p = (const unsigned char *)msg_addr->mailbox; *p != '\0'; p++) {
                if (!smtp_char_is_qpair(*p))
                        return -1;
        }