Fix segfault after missing transmit time stamp.

If the networking stack fails to provide a transmit time stamp, then we
might feed uninitialized stack data to the CMSG(3) macros. This can result
in a segfault or other badness.

The fix is to simply clear the control buffer in advance.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
master
Richard Cochran 2012-03-11 09:45:23 +01:00
parent 150da0cba9
commit a9e88a0a49
1 changed files with 1 additions and 0 deletions

1
udp.c
View File

@ -257,6 +257,7 @@ static int receive(int fd, void *buf, int buflen,
struct msghdr msg;
struct timespec *ts = NULL;
memset(control, 0, sizeof(control));
memset(&msg, 0, sizeof(msg));
msg.msg_iov = &iov;
msg.msg_iovlen = 1;