summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorlijia <[email protected]>2021-07-20 18:41:44 +0800
committerlijia <[email protected]>2021-07-20 18:41:44 +0800
commitcd2dcaf6a65f5f5b38760b31bed53367adf0190c (patch)
tree25939ae3f03827b3c5d5f9936d3c4346f834079b /src/common
parenta893719c47abafe1b2f41bd186b4d9493dda30d8 (diff)
TSG-7132, 修复socks,http_proxy等代理层打印日志类型读内存越界BUG;
解决开启ASAN地址检查后, sapp调用strdup()无法运行的问题.
Diffstat (limited to 'src/common')
-rw-r--r--src/common/stream_addr_inet.c59
1 files changed, 29 insertions, 30 deletions
diff --git a/src/common/stream_addr_inet.c b/src/common/stream_addr_inet.c
index d22df42..f3b577a 100644
--- a/src/common/stream_addr_inet.c
+++ b/src/common/stream_addr_inet.c
@@ -39,6 +39,7 @@ static int __addr_arp_n2p_fun(const struct layer_addr *paddr, char *buf, int buf
static int __addr_ppp_n2p_fun(const struct layer_addr *paddr, char *buf, int buf_len);
static int __addr_pptp_n2p_fun(const struct layer_addr *paddr, char *buf, int buf_len);
static int __addr_socks_n2p_fun(const struct layer_addr *paddr, char *buf, int buf_len);
+static int __addr_http_proxy_n2p_fun(const struct layer_addr *paddr, char *buf, int buf_len);
static int __addr_openvpn_n2p_fun(const struct layer_addr *paddr, char *buf, int buf_len);
static int __addr_mac_in_mac_n2p_fun(const struct layer_addr *paddr, char *buf, int buf_len);
static int __addr_gtp_n2p_fun(const struct layer_addr *paddr, char *buf, int buf_len);
@@ -64,6 +65,7 @@ static int __addr_ppp_pton(char *addr_str, addr_continuous_bin_t *addr_bin_val);
static int __addr_pptp_pton(char *addr_str, addr_continuous_bin_t *addr_bin_val);
static int __addr_sockv4_pton(char *addr_str, addr_continuous_bin_t *addr_bin_val);
static int __addr_openvpn_pton(char *addr_str, addr_continuous_bin_t *addr_bin_val);
+static int __addr_http_proxy_pton(char *addr_str, addr_continuous_bin_t *addr_bin_val);
static int __addr_mac_in_mac_pton(char *addr_str, addr_continuous_bin_t *addr_bin_val);
static const char *__layer_addr_ntop (const struct streaminfo *stream, int thread_index);
static int __addr_gtp_pton(char *addr_str, addr_continuous_bin_t *addr_bin_val);
@@ -99,6 +101,8 @@ static const addr_convert_t G_ADDR_CONVERT_HANDLE[] =
{ADDR_TYPE_PPP, STREAM_TYPE_NON,"ADDR_TYPE_PPP", "PPP", "PPP<",__addr_ppp_n2p_fun,__addr_ppp_pton, "ppp"},/* 14 */
{ADDR_TYPE_IPV4, STREAM_TYPE_SOCKS4,"ADDR_TYPE_SOCKS", "SOCKS", "SOCKS<",__addr_socks_n2p_fun,__addr_sockv4_pton, "socks"},/* 14 */
{ADDR_TYPE_IPV4, STREAM_TYPE_SOCKS5,"ADDR_TYPE_SOCKS", "SOCKS", "SOCKS<",__addr_socks_n2p_fun,__addr_sockv4_pton, "socks"},/* 14 */
+ {ADDR_TYPE_IPV4, STREAM_TYPE_HTTP_PROXY,"ADDR_TYPE_HTTP_PROXY", "HTTP_PROXY", "HTTP_PROXY<",__addr_http_proxy_n2p_fun,__addr_http_proxy_pton, "http_proxy"},
+ {ADDR_TYPE_IPV6, STREAM_TYPE_HTTP_PROXY,"ADDR_TYPE_HTTP_PROXY", "HTTP_PROXY", "HTTP_PROXY<",__addr_http_proxy_n2p_fun,__addr_http_proxy_pton, "http_proxy"},
{ADDR_TYPE_PPTP, STREAM_TYPE_PPTP,"ADDR_TYPE_PPPTP", "PPTP", "PPTP<",__addr_pptp_n2p_fun, __addr_pptp_pton, "pptp"}, /* 15 */
{ADDR_TYPE_MAC_IN_MAC, STREAM_TYPE_NON, "ADDR_TYPE_MAC_IN_MAC", "MAC_IN_MAC", "MAC_IN_MAC<",__addr_mac_in_mac_n2p_fun,__addr_mac_in_mac_pton, "mac_in_mac"}, /* 4 */
{ADDR_TYPE_IPV4, STREAM_TYPE_OPENVPN,"ADDR_TYPE_OPENVPN", "OpenVPN", "OpenVPN<",__addr_openvpn_n2p_fun,__addr_openvpn_pton, "openvpn"},/* 2017-02-10 lijia add */
@@ -929,6 +933,16 @@ static int __addr_openvpn_pton(char *addr_str, addr_continuous_bin_t *addr_bin_v
return 0;
}
+static int __addr_http_proxy_pton(char *addr_str, addr_continuous_bin_t *addr_bin_val)
+{
+ addr_bin_val->stream.addr.addrtype = ADDR_TYPE_IPV4;
+ addr_bin_val->stream.type = STREAM_TYPE_HTTP_PROXY;
+ addr_bin_val->stream.addr.paddr = addr_bin_val->addr_value;
+
+ return 0;
+}
+
+
/*
return val:
<0 : error;
@@ -1689,6 +1703,21 @@ static int __addr_vxlan_n2p_fun(const struct layer_addr *paddr, char *buf, int b
return addr_len;
}
+
+static int __addr_http_proxy_n2p_fun(const struct layer_addr *paddr, char *buf, int buf_len)
+{
+#define __HTTPPRO_ADDR_STRING "NULL"
+
+ int addr_len = strlen(__HTTPPRO_ADDR_STRING);
+ if(buf_len <= addr_len + 1){
+ return -1;
+ }
+ strncpy(buf, __HTTPPRO_ADDR_STRING, addr_len + 1);
+
+ return addr_len + 1;
+}
+
+
static const char *addr_and_stream_type_to_prefix(UCHAR stream_type, enum addr_type_t layer_type)
{
int i;
@@ -1951,45 +1980,15 @@ char *layer_addr_ntop_r(const struct streaminfo *pstream, char *out_buf, int out
return NULL;
}
-/*
- sappΪ�˲�����׼, ijЩ���鹹��, ��ʱҵ���������ӡ��־��Ƚ��Ի�, �˴�ʹ��"_PAD"��ʶһ��, ���������ڵ�������.
-*/
-const char *__layer_addr_prefix_ntop_pad(const struct streaminfo_private *pstream_pr)
-{
- const char *addr_prefix = NULL;
-
- switch(pstream_pr->stream_public.addr.addrtype){
- case ADDR_TYPE_MPLS:
- addr_prefix = "_PAD_MPLS";
- break;
-
- case ADDR_TYPE_VLAN:
- addr_prefix = "_PAD_VLAN";
- break;
-
- default:
- addr_prefix = NULL;
- break;
- }
-
- return addr_prefix;
-}
-
-
const char *layer_addr_prefix_ntop(const struct streaminfo *pstream)
{
int i;
const char *addr_type_str = NULL;
- const struct streaminfo_private *pstream_pr = (struct streaminfo_private *)pstream;
if(NULL == pstream){
return NULL;
}
- if(pstream_pr->addr_skip_for_layer_cmp){
- return __layer_addr_prefix_ntop_pad(pstream_pr);
- }
-
for(i = __ADDR_TYPE_INIT+1; G_ADDR_CONVERT_HANDLE[i].addr_type_bin!= __ADDR_TYPE_MAX; i++){
if((G_ADDR_CONVERT_HANDLE[i].addr_type_bin == pstream->addr.addrtype)
&&(G_ADDR_CONVERT_HANDLE[i].stream_type == pstream->type)){