Driver: fortconf: Fix fort_mem_cmp()

This commit is contained in:
Nodir Temirkhodjaev 2024-10-27 17:50:14 +05:00
parent cd73f49f83
commit 53bb7f48ad
3 changed files with 7 additions and 5 deletions

View File

@ -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)

View File

@ -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(

View File

@ -1,5 +1,7 @@
#include "iprange.h"
#include <common/fortconf.h>
#include <util/stringutil.h>
#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)