vcl: zero out cmsg for recvmsg API 46/39246/2
authorSteven Luong <sluong@cisco.com>
Wed, 19 Jul 2023 06:25:15 +0000 (23:25 -0700)
committersteven luong <sluong@cisco.com>
Wed, 19 Jul 2023 06:37:29 +0000 (06:37 +0000)
When msg->msg_controllen is set in recvmsg, the caller wants to receive
additional information about the messages. However, they might not
always be available. In that case, we should clear cmsg since
the caller uses CMSG_NXTHDR which might access uninitialized fields in
cmsg.

Type: fix

Change-Id: Ifdf9634bfcb1427f7ae3812014a46bfd7f4bc473
Signed-off-by: Steven Luong <sluong@cisco.com>
src/vcl/ldp.c

index ffe1673..2256a2b 100644 (file)
@@ -1748,6 +1748,7 @@ ldp_make_cmsg (vls_handle_t vlsh, struct msghdr *msg)
   struct cmsghdr *cmsg;
 
   cmsg = CMSG_FIRSTHDR (msg);
+  memset (cmsg, 0, sizeof (*cmsg));
 
   if (!vls_attr (vlsh, VPPCOM_ATTR_GET_IP_PKTINFO, (void *) &optval, &optlen))
     return 0;