mirror of
https://github.com/bol-van/zapret.git
synced 2025-08-10 01:02:03 +03:00
nfqws,tpws: fix possible crashes or high memory usage if hostlist has duplicate hostnames
This commit is contained in:
@@ -534,3 +534,7 @@ nfqws: ts fooling
|
|||||||
blockcheck: test ts fooling
|
blockcheck: test ts fooling
|
||||||
blockcheck: auto enable tcp timestamps in windows
|
blockcheck: auto enable tcp timestamps in windows
|
||||||
tpws,nfqws: special handling of IP-like hostnames. strip :port from hostname:port
|
tpws,nfqws: special handling of IP-like hostnames. strip :port from hostname:port
|
||||||
|
|
||||||
|
v71.4
|
||||||
|
|
||||||
|
nfqws,tpws: fix possible crashes or high memory usage if hostlist has duplicate hostnames
|
||||||
|
13
nfq/pools.c
13
nfq/pools.c
@@ -12,7 +12,7 @@
|
|||||||
HASH_DEL(*ppool, elem); \
|
HASH_DEL(*ppool, elem); \
|
||||||
free(elem); \
|
free(elem); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define ADD_STR_POOL(etype, ppool, keystr, keystr_len) \
|
#define ADD_STR_POOL(etype, ppool, keystr, keystr_len) \
|
||||||
etype *elem; \
|
etype *elem; \
|
||||||
if (!(elem = (etype*)malloc(sizeof(etype)))) \
|
if (!(elem = (etype*)malloc(sizeof(etype)))) \
|
||||||
@@ -25,7 +25,7 @@
|
|||||||
memcpy(elem->str, keystr, keystr_len); \
|
memcpy(elem->str, keystr, keystr_len); \
|
||||||
elem->str[keystr_len] = 0; \
|
elem->str[keystr_len] = 0; \
|
||||||
oom = false; \
|
oom = false; \
|
||||||
HASH_ADD_KEYPTR(hh, *ppool, elem->str, strlen(elem->str), elem); \
|
HASH_ADD_KEYPTR(hh, *ppool, elem->str, keystr_len, elem); \
|
||||||
if (oom) \
|
if (oom) \
|
||||||
{ \
|
{ \
|
||||||
free(elem->str); \
|
free(elem->str); \
|
||||||
@@ -33,9 +33,12 @@
|
|||||||
return false; \
|
return false; \
|
||||||
}
|
}
|
||||||
#define ADD_HOSTLIST_POOL(etype, ppool, keystr, keystr_len, flg) \
|
#define ADD_HOSTLIST_POOL(etype, ppool, keystr, keystr_len, flg) \
|
||||||
ADD_STR_POOL(etype,ppool,keystr,keystr_len); \
|
etype *elem_find; \
|
||||||
elem->flags = flg;
|
HASH_FIND(hh, *ppool, keystr, keystr_len, elem_find); \
|
||||||
|
if (!elem_find) { \
|
||||||
|
ADD_STR_POOL(etype,ppool,keystr,keystr_len); \
|
||||||
|
elem->flags = flg; \
|
||||||
|
}
|
||||||
|
|
||||||
#undef uthash_nonfatal_oom
|
#undef uthash_nonfatal_oom
|
||||||
#define uthash_nonfatal_oom(elt) ut_oom_recover(elt)
|
#define uthash_nonfatal_oom(elt) ut_oom_recover(elt)
|
||||||
|
11
tpws/pools.c
11
tpws/pools.c
@@ -25,7 +25,7 @@
|
|||||||
memcpy(elem->str, keystr, keystr_len); \
|
memcpy(elem->str, keystr, keystr_len); \
|
||||||
elem->str[keystr_len] = 0; \
|
elem->str[keystr_len] = 0; \
|
||||||
oom = false; \
|
oom = false; \
|
||||||
HASH_ADD_KEYPTR(hh, *ppool, elem->str, strlen(elem->str), elem); \
|
HASH_ADD_KEYPTR(hh, *ppool, elem->str, keystr_len, elem); \
|
||||||
if (oom) \
|
if (oom) \
|
||||||
{ \
|
{ \
|
||||||
free(elem->str); \
|
free(elem->str); \
|
||||||
@@ -33,9 +33,12 @@
|
|||||||
return false; \
|
return false; \
|
||||||
}
|
}
|
||||||
#define ADD_HOSTLIST_POOL(etype, ppool, keystr, keystr_len, flg) \
|
#define ADD_HOSTLIST_POOL(etype, ppool, keystr, keystr_len, flg) \
|
||||||
ADD_STR_POOL(etype,ppool,keystr,keystr_len); \
|
etype *elem_find; \
|
||||||
elem->flags = flg;
|
HASH_FIND(hh, *ppool, keystr, keystr_len, elem_find); \
|
||||||
|
if (!elem_find) { \
|
||||||
|
ADD_STR_POOL(etype,ppool,keystr,keystr_len); \
|
||||||
|
elem->flags = flg; \
|
||||||
|
}
|
||||||
|
|
||||||
#undef uthash_nonfatal_oom
|
#undef uthash_nonfatal_oom
|
||||||
#define uthash_nonfatal_oom(elt) ut_oom_recover(elt)
|
#define uthash_nonfatal_oom(elt) ut_oom_recover(elt)
|
||||||
|
Reference in New Issue
Block a user