Skip to content
Permalink
Browse files Browse the repository at this point in the history
Fix #1: Ensure recv buf is always NUL terminated
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
  • Loading branch information
troglobit committed Jul 24, 2019
1 parent 8c22bef commit ce04b1f
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions ssdpd.c
Expand Up @@ -432,13 +432,11 @@ static void ssdp_recv(int sd)
ssize_t len;
struct sockaddr sa;
socklen_t salen;
char buf[MAX_PKT_SIZE];
char buf[MAX_PKT_SIZE + 1];

memset(buf, 0, sizeof(buf));
len = recvfrom(sd, buf, sizeof(buf), MSG_DONTWAIT, &sa, &salen);
len = recvfrom(sd, buf, sizeof(buf) - 1, MSG_DONTWAIT, &sa, &salen);
if (len > 0) {
buf[len] = 0;

if (sa.sa_family != AF_INET)
return;

Expand Down

0 comments on commit ce04b1f

Please sign in to comment.