Browse code

core: raw sock - reset the rcv_msg and proper test for totlen

(cherry picked from commit 145e3a1e461dd53fb1e06bae619d20a09dcffe75)
(cherry picked from commit 6bf6cfbb90c3fd29cb0c5c079b0eef44892690bf)

Daniel-Constantin Mierla authored on 15/06/2018 09:50:31
Showing 1 changed files
... ...
@@ -228,6 +228,7 @@ int recvpkt4(int sock, char* buf, int len, union sockaddr_union* from,
228 228
 
229 229
 	iov[0].iov_base=buf;
230 230
 	iov[0].iov_len=len;
231
+	memset(&rcv_msg, 0, sizeof(struct msghdr));
231 232
 	rcv_msg.msg_name=from;
232 233
 	rcv_msg.msg_namelen=sockaddru_len(*from);
233 234
 	rcv_msg.msg_control=msg_ctrl_buf;
... ...
@@ -603,7 +604,7 @@ int raw_iphdr_udp4_send(int rsock, char* buf, unsigned int len,
603 604
 	int ret;
604 605
 
605 606
 	totlen = len + sizeof(hdr);
606
-	if (unlikely(totlen) > 65535)
607
+	if (unlikely(totlen > 65535))
607 608
 		return -2;
608 609
 	memset(&snd_msg, 0, sizeof(snd_msg));
609 610
 	snd_msg.msg_name=&to->sin;