From: Douglas Bagnall Date: Mon, 8 Apr 2024 05:08:03 +0000 (+1200) Subject: s3:libsmb:nmblib: use NUMERIC_CMP in status_compare X-Git-Tag: ldb-2.8.1~16 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=9314eaaba91310503130878938a637c232b54ba4;p=thirdparty%2Fsamba.git s3:libsmb:nmblib: use NUMERIC_CMP in status_compare BUG: https://bugzilla.samba.org/show_bug.cgi?id=15625 Signed-off-by: Douglas Bagnall Reviewed-by: Andrew Bartlett (cherry picked from commit 31c322874b8b65518cec945e05a42fd014e6390b) --- diff --git a/source3/libsmb/nmblib.c b/source3/libsmb/nmblib.c index c90e92ebb69..ea4c5b7b35a 100644 --- a/source3/libsmb/nmblib.c +++ b/source3/libsmb/nmblib.c @@ -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); } /****************************************************************************