sd-radv: when receiving a too short packet, make sure we dequeue it

This commit is contained in:
Lennart Poettering
2018-11-26 22:31:15 +01:00
parent e55a6eaeb9
commit cfffddeac5
+7 -3
View File
@@ -229,9 +229,8 @@ static int radv_recv(sd_event_source *s, int fd, uint32_t revents, void *userdat
assert(ra->event);
buflen = next_datagram_size_fd(fd);
if ((unsigned) buflen < sizeof(struct nd_router_solicit))
return log_radv("Too short packet received");
if (buflen < 0)
return (int) buflen;
buf = new0(char, buflen);
if (!buf)
@@ -264,6 +263,11 @@ static int radv_recv(sd_event_source *s, int fd, uint32_t revents, void *userdat
return 0;
}
if ((size_t) buflen < sizeof(struct nd_router_solicit)) {
log_radv("Too short packet received");
return 0;
}
(void) in_addr_to_string(AF_INET6, (union in_addr_union*) &src, &addr);
r = radv_send(ra, &src, ra->lifetime);