s3:libsmb:namequery: use NUMERIC_CMP in addr_compare
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Wed, 3 Apr 2024 03:13:07 +0000 (16:13 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Wed, 10 Apr 2024 22:56:33 +0000 (22:56 +0000)
This one was OK, as the numbers are tightly bound, but there is no
real reason not to do it safely.

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>
source3/libsmb/namequery.c

index f787e516da0c9b597d07d36d60095d1f24905dc7..8f6a9b51f8161d5f6ffe8e411567ddd2e733812e 100644 (file)
@@ -34,6 +34,7 @@
 #include "lib/gencache.h"
 #include "librpc/gen_ndr/dns.h"
 #include "lib/util/util_net.h"
+#include "lib/util/tsort.h"
 #include "lib/util/string_wrappers.h"
 
 /* nmbd.c sets this to True. */
@@ -1183,7 +1184,7 @@ static int addr_compare(const struct sockaddr_storage *ss1,
                        max_bits2 += 128;
                }
        }
-       return max_bits2 - max_bits1;
+       return NUMERIC_CMP(max_bits2, max_bits1);
 }
 
 /*