ab660b
From 30feadb676a0792036a0f64309235c5767e2ee76 Mon Sep 17 00:00:00 2001
ab660b
From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= <marcandre.lureau@redhat.com>
ab660b
Date: Fri, 4 Jun 2021 16:32:55 +0400
ab660b
Subject: [PATCH 4/7] upd6: check udp6_input buffer size
ab660b
MIME-Version: 1.0
ab660b
Content-Type: text/plain; charset=UTF-8
ab660b
Content-Transfer-Encoding: 8bit
ab660b
ab660b
Fixes: CVE-2021-3593
ab660b
Fixes: https://gitlab.freedesktop.org/slirp/libslirp/-/issues/45
ab660b
ab660b
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
ab660b
(cherry picked from commit de71c15de66ba9350bf62c45b05f8fbff166517b)
ab660b
---
ab660b
 src/udp6.c | 5 ++++-
ab660b
 1 file changed, 4 insertions(+), 1 deletion(-)
ab660b
ab660b
diff --git a/src/udp6.c b/src/udp6.c
ab660b
index fdd8089..236b962 100644
ab660b
--- a/src/udp6.c
ab660b
+++ b/src/udp6.c
ab660b
@@ -29,7 +29,10 @@ void udp6_input(struct mbuf *m)
ab660b
     ip = mtod(m, struct ip6 *);
ab660b
     m->m_len -= iphlen;
ab660b
     m->m_data += iphlen;
ab660b
-    uh = mtod(m, struct udphdr *);
ab660b
+    uh = mtod_check(m, sizeof(struct udphdr));
ab660b
+    if (uh == NULL) {
ab660b
+        goto bad;
ab660b
+    }
ab660b
     m->m_len += iphlen;
ab660b
     m->m_data -= iphlen;
ab660b
 
ab660b
-- 
ab660b
2.29.0
ab660b