ldb: avoid non-transitive comparison in ldb_val_cmp()
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Wed, 3 Apr 2024 22:22:58 +0000 (11:22 +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/ldb/common/ldb_msg.c

index 53f675ed18342af2c1e228ffac992d8d2050436b..9cb26d8bd89d05bc4407a8fdac1f7f269c2e5401 100644 (file)
@@ -93,7 +93,7 @@ struct ldb_val *ldb_msg_find_val(const struct ldb_message_element *el,
 static int ldb_val_cmp(const struct ldb_val *v1, const struct ldb_val *v2)
 {
        if (v1->length != v2->length) {
-               return v1->length - v2->length;
+               return NUMERIC_CMP(v1->length, v2->length);
        }
        return memcmp(v1->data, v2->data, v1->length);
 }