From 53bb7f48ad434579950b22dcf870086d550f6aac Mon Sep 17 00:00:00 2001 From: Nodir Temirkhodjaev Date: Sun, 27 Oct 2024 17:50:14 +0500 Subject: [PATCH] Driver: fortconf: Fix fort_mem_cmp() --- src/driver/common/fortconf.c | 4 +--- src/driver/common/fortconf.h | 2 ++ src/ui/util/net/iprange.cpp | 6 ++++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/driver/common/fortconf.c b/src/driver/common/fortconf.c index bade7b59..50c3a9f7 100644 --- a/src/driver/common/fortconf.c +++ b/src/driver/common/fortconf.c @@ -42,8 +42,6 @@ static BOOL fort_conf_ip4_find(const UINT32 *iparr, UINT32 ip, UINT32 count, BOO return high >= 0 && ip >= iparr[high] && ip <= iparr[count + high]; } -#define fort_ip6_cmp(l, r) fort_mem_cmp(l, r, sizeof(ip6_addr_t)) - static BOOL fort_conf_ip6_find( const ip6_addr_t *iparr, const ip6_addr_t *ip, UINT32 count, BOOL is_range) { @@ -97,7 +95,7 @@ static BOOL fort_conf_ip6_find( FORT_API int fort_mem_cmp(const void *p1, const void *p2, UINT32 len) { const size_t n = RtlCompareMemory(p1, p2, len); - return (n == len) ? 0 : (((const char *) p1)[n] - ((const char *) p2)[n]); + return (n == len) ? 0 : (((unsigned char *) p1)[n] - ((unsigned char *) p2)[n]); } FORT_API BOOL fort_mem_eql(const void *p1, const void *p2, UINT32 len) diff --git a/src/driver/common/fortconf.h b/src/driver/common/fortconf.h index 0098fa9e..239387e2 100644 --- a/src/driver/common/fortconf.h +++ b/src/driver/common/fortconf.h @@ -347,6 +347,8 @@ extern "C" { FORT_API int fort_mem_cmp(const void *p1, const void *p2, UINT32 len); +#define fort_ip6_cmp(l, r) fort_mem_cmp(l, r, sizeof(ip6_addr_t)) + FORT_API BOOL fort_mem_eql(const void *p1, const void *p2, UINT32 len); FORT_API BOOL fort_conf_ip_inlist( diff --git a/src/ui/util/net/iprange.cpp b/src/ui/util/net/iprange.cpp index 0e819f64..09419a2c 100644 --- a/src/ui/util/net/iprange.cpp +++ b/src/ui/util/net/iprange.cpp @@ -1,5 +1,7 @@ #include "iprange.h" +#include + #include #include "netutil.h" @@ -16,9 +18,9 @@ inline bool checkIp6MaskBitsCount(const int nbits) return (nbits >= 0 && nbits <= 128); } -inline bool compareLessIp6(const ip6_addr_t l, const ip6_addr_t r) +inline bool compareLessIp6(const ip6_addr_t &l, const ip6_addr_t &r) { - return memcmp(&l, &r, sizeof(ip6_addr_t)) < 0; + return fort_ip6_cmp(&l, &r) < 0; } inline void sortIp6Array(ip6_arr_t &array)