aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRalf Haferkamp <rhafer@suse.com>2020-07-03 14:51:16 +0200
committerRalf Haferkamp <rhafer@suse.com>2020-07-03 14:51:16 +0200
commitc7ede54cbd2e2b25385325600958ba0124e31cc0 (patch)
treefcaf4d0a05f1ef7c20238e1a6489286d29ff374a
parentd877d74bea1b0c5680213ecd53fa630f6a8b1aba (diff)
downloadslirp-c7ede54cbd2e2b25385325600958ba0124e31cc0.zip
slirp-c7ede54cbd2e2b25385325600958ba0124e31cc0.tar.gz
slirp-c7ede54cbd2e2b25385325600958ba0124e31cc0.tar.bz2
Drop bogus IPv6 messages
Drop IPv6 message shorter than what's mentioned in the payload length header (+ the size of the IPv6 header). They're invalid an could lead to data leakage in icmp6_send_echoreply().
-rw-r--r--src/ip6_input.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/ip6_input.c b/src/ip6_input.c
index dfcbfd6..d88d1ab 100644
--- a/src/ip6_input.c
+++ b/src/ip6_input.c
@@ -49,6 +49,13 @@ void ip6_input(struct mbuf *m)
goto bad;
}
+ // Check if the message size is big enough to hold what's
+ // set in the payload length header. If not this is an invalid
+ // packet
+ if (m->m_len < ntohs(ip6->ip_pl) + sizeof(struct ip6)) {
+ goto bad;
+ }
+
/* check ip_ttl for a correct ICMP reply */
if (ip6->ip_hl == 0) {
icmp6_send_error(m, ICMP6_TIMXCEED, ICMP6_TIMXCEED_INTRANS);