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