]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
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)
committerJule Anger <janger@samba.org>
Mon, 10 Jun 2024 13:25:16 +0000 (13:25 +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>
(cherry picked from commit 3414a894ad6640fa8e282d650b1cc5319991545f)

source3/libsmb/namequery.c

index 01bac9297765798b96f31f7d6280c2097a2c18e5..8ae4004a98c24ffc5145a657b3953fcb36a650e1 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. */
@@ -1178,7 +1179,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);
 }
 
 /*