]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
util:datablob: avoid non-transitive comparison in data_blob_cmp()
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Wed, 3 Apr 2024 22:07:06 +0000 (11:07 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Wed, 10 Apr 2024 22:56:33 +0000 (22:56 +0000)
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>
lib/util/data_blob.c

index 69a340c6fb8d9613f321c0eab229f4eca7b2b7d1..15582000205328a38c1d81bd0b8f096a415f41d7 100644 (file)
@@ -22,6 +22,7 @@
 #include "attr.h"
 #include "data_blob.h"
 #include "lib/util/samba_util.h"
+#include "lib/util/tsort.h"
 
 const DATA_BLOB data_blob_null = { NULL, 0 };
 
@@ -121,12 +122,12 @@ _PUBLIC_ int data_blob_cmp(const DATA_BLOB *d1, const DATA_BLOB *d2)
                return 1;
        }
        if (d1->data == d2->data) {
-               return d1->length - d2->length;
+               return NUMERIC_CMP(d1->length, d2->length);
        }
        ret = memcmp(d1->data, d2->data, MIN(d1->length, d2->length));
        if (ret == 0) {
                /* Note this ordering is used in conditional aces */
-               return d1->length - d2->length;
+               return NUMERIC_CMP(d1->length, d2->length);
        }
        return ret;
 }