]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3:libsmb:nmblib: use NUMERIC_CMP in status_compare
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Mon, 8 Apr 2024 05:08:03 +0000 (17:08 +1200)
committerJule Anger <janger@samba.org>
Mon, 10 Jun 2024 13:25:17 +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>
(cherry picked from commit 31c322874b8b65518cec945e05a42fd014e6390b)

source3/libsmb/nmblib.c

index c90e92ebb697bfdfcce82ddfc5d163749808f017..ea4c5b7b35a9d7f5f5ba72f74015a4efaea96830 100644 (file)
@@ -1229,8 +1229,10 @@ static unsigned char sort_ip[4];
 
 static int name_query_comp(unsigned char *p1, unsigned char *p2)
 {
-       return matching_len_bits(p2+2, sort_ip, 4) -
-               matching_len_bits(p1+2, sort_ip, 4);
+       int a = matching_len_bits(p1+2, sort_ip, 4);
+       int b = matching_len_bits(p2+2, sort_ip, 4);
+       /* reverse sort -- p2 derived value comes first */
+       return NUMERIC_CMP(b, a);
 }
 
 /****************************************************************************