]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3:util:sharesec ace_compare() uses NUMERIC_CMP()
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Thu, 4 Apr 2024 01:08:02 +0000 (14:08 +1300)
committerJule Anger <janger@samba.org>
Mon, 10 Jun 2024 13:25:17 +0000 (13:25 +0000)
ace->access_mask is uint32_t, so can overflow a signed int.
This would be easy to trigger, as it is a flags field rather than an
allocation count.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15625

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
(cherry picked from commit e35d54fd4d381df67ab9b4f8390e2109b2142678)

source3/utils/sharesec.c

index 9b8064de7027aef436825bca66fa0c56e16c2163..8f6117209f4239c2f37103621b52d1096363a506 100644 (file)
@@ -119,19 +119,19 @@ static int ace_compare(struct security_ace *ace1, struct security_ace *ace2)
                return 0;
 
        if (ace1->type != ace2->type)
-               return ace2->type - ace1->type;
+               return NUMERIC_CMP(ace2->type, ace1->type);
 
        if (dom_sid_compare(&ace1->trustee, &ace2->trustee))
                return dom_sid_compare(&ace1->trustee, &ace2->trustee);
 
        if (ace1->flags != ace2->flags)
-               return ace1->flags - ace2->flags;
+               return NUMERIC_CMP(ace1->flags, ace2->flags);
 
        if (ace1->access_mask != ace2->access_mask)
-               return ace1->access_mask - ace2->access_mask;
+               return NUMERIC_CMP(ace1->access_mask, ace2->access_mask);
 
        if (ace1->size != ace2->size)
-               return ace1->size - ace2->size;
+               return NUMERIC_CMP(ace1->size, ace2->size);
 
        return memcmp(ace1, ace2, sizeof(struct security_ace));
 }