Skip to content

Commit

Permalink
Fix segfault after missing transmit time stamp.
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
richardcochran committed Mar 11, 2012
1 parent 150da0c commit a9e88a0
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions udp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit a9e88a0

Please sign in to comment.