aboutgitcodebugslistschat
diff options
context:
space:
mode:
-rw-r--r--icmp.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/icmp.c b/icmp.c
index 0fe2366..7045d5f 100644
--- a/icmp.c
+++ b/icmp.c
@@ -94,6 +94,7 @@ void icmp_sock_handler(const struct ctx *c, union epoll_ref ref,
struct icmphdr *ih4 = (struct icmphdr *)buf;
if (sr.sa_family != AF_INET || (size_t)n < sizeof(*ih4) ||
+ (size_t)n > USHRT_MAX - ETH_HLEN - sizeof(struct iphdr) ||
ih4->type != ICMP_ECHOREPLY)
goto unexpected;
@@ -104,6 +105,7 @@ void icmp_sock_handler(const struct ctx *c, union epoll_ref ref,
struct icmp6hdr *ih6 = (struct icmp6hdr *)buf;
if (sr.sa_family != AF_INET6 || (size_t)n < sizeof(*ih6) ||
+ (size_t)n > USHRT_MAX - ETH_HLEN - sizeof(struct ipv6hdr) ||
ih6->icmp6_type != ICMPV6_ECHO_REPLY)
goto unexpected;