20180718-2
修改valgrind检查到一处invalid write: kni.c:2291memset(g_kni_comminfo.fd_tun,0,sizeof(g_kni_comminfo.thread_num*sizeof(int)));修改为: memset(g_kni_comminfo.fd_tun,0,g_kni_comminfo.thread_num*sizeof(int));
This commit is contained in:
10
kni.c
10
kni.c
@@ -240,7 +240,7 @@ static int kni_send_fds(int socket, int *fds, int n,int protocol)
|
||||
int flags=MSG_NOSIGNAL;
|
||||
struct msghdr msg = {0};
|
||||
struct cmsghdr *cmsg;
|
||||
char buf[CMSG_SPACE(n * sizeof(int))], dup[256];
|
||||
char buf[CMSG_SPACE(n * sizeof(int))], dup[256]={0};
|
||||
memset(buf, 0, sizeof(buf));
|
||||
struct iovec io = { .iov_base = &dup, .iov_len = sizeof(dup) };
|
||||
|
||||
@@ -485,6 +485,12 @@ int tun_write_data_v6(int fd,char* send_buf,int send_buflen)
|
||||
|
||||
int kni_sendpkt_routdir(int thread_seq,int iplen,char* ip,struct stream_tuple4_v4* ipv4_addr,int iprever_flag,int routdir,uchar* smac,uchar* dmac)
|
||||
{
|
||||
if((routdir!=0)&&(routdir!=1))
|
||||
{
|
||||
MESA_handle_runtime_log(g_kni_comminfo.logger, RLOG_LV_DEBUG,"kni_sendpkt_routdir","routdir:%d",routdir);
|
||||
return -1;
|
||||
}
|
||||
|
||||
int ret=0;
|
||||
int buflen=iplen+KNI_ETHER_LEN;
|
||||
|
||||
@@ -2288,7 +2294,7 @@ extern "C" char kni_init()
|
||||
}
|
||||
|
||||
g_kni_comminfo.fd_tun=(int*)malloc(g_kni_comminfo.thread_num*sizeof(int));
|
||||
memset(g_kni_comminfo.fd_tun,0,sizeof(g_kni_comminfo.thread_num*sizeof(int)));
|
||||
memset(g_kni_comminfo.fd_tun,0,g_kni_comminfo.thread_num*sizeof(int));
|
||||
|
||||
ret=tun_alloc_mq(g_kni_comminfo.tun_name,g_kni_comminfo.thread_num,g_kni_comminfo.fd_tun);
|
||||
if(ret<0)
|
||||
|
||||
Reference in New Issue
Block a user