]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-mail: Explicitly return -1/1/0 for RFC2231 parameter comparisons
authorFred Morcos <fred.morcos@open-xchange.com>
Mon, 10 Feb 2025 13:30:58 +0000 (14:30 +0100)
committerFred Morcos <fred.morcos@open-xchange.com>
Mon, 10 Feb 2025 13:33:15 +0000 (14:33 +0100)
This avoids an out of range cast stemming from casting unsigned values to signed.

src/lib-mail/rfc2231-parser.c

index 344bb5358decb5bdb694d0125e513c3c2fe2a88c..2635a9a80c7ddbcf14f427b194ebab524ad82206 100644 (file)
@@ -105,7 +105,11 @@ static int rfc2231_parameter_cmp(const struct rfc2231_parameter *r1,
        int ret = strcmp(r1->key, r2->key);
        if (ret != 0)
                return ret;
-       return (int)r1->idx - (int)r2->idx;
+       if (r1->idx < r2->idx)
+               return -1;
+       else if (r1->idx > r2->idx)
+               return 1;
+       return 0;
 }
 
 static bool result_contains(const ARRAY_TYPE(const_string) *result,