]> 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)
committerJule Anger <janger@samba.org>
Mon, 10 Jun 2024 13:25:16 +0000 (13:25 +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>
(backported from commit e1519c3667841ce27b15983eae378799ef9936f7)
[dbagnall@samba.org: changed in master for conditional ACEs]

lib/util/data_blob.c

index 677f7c192111ffa71f3353b89abb36f028f8c996..687b6c8d3d5e2d906d4fb6a05a7552ff48f80c63 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,11 +122,11 @@ _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) {
-               return d1->length - d2->length;
+               return NUMERIC_CMP(d1->length, d2->length);
        }
        return ret;
 }