cd7acf
From 0f017f39a390d8fa4ae817f45fbf71a0c8332860 Mon Sep 17 00:00:00 2001
cd7acf
From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= <marcandre.lureau@redhat.com>
cd7acf
Date: Fri, 4 Jun 2021 16:15:14 +0400
cd7acf
Subject: [PATCH 3/7] bootp: check bootp_input buffer size
cd7acf
MIME-Version: 1.0
cd7acf
Content-Type: text/plain; charset=UTF-8
cd7acf
Content-Transfer-Encoding: 8bit
cd7acf
cd7acf
Fixes: CVE-2021-3592
cd7acf
Fixes: https://gitlab.freedesktop.org/slirp/libslirp/-/issues/44
cd7acf
cd7acf
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
cd7acf
(cherry picked from commit 2eca0838eee1da96204545e22cdaed860d9d7c6c)
cd7acf
---
cd7acf
 src/bootp.c | 4 ++--
cd7acf
 1 file changed, 2 insertions(+), 2 deletions(-)
cd7acf
cd7acf
diff --git a/src/bootp.c b/src/bootp.c
cd7acf
index e0db8d1..cafa1eb 100644
cd7acf
--- a/src/bootp.c
cd7acf
+++ b/src/bootp.c
cd7acf
@@ -365,9 +365,9 @@ static void bootp_reply(Slirp *slirp,
cd7acf
 
cd7acf
 void bootp_input(struct mbuf *m)
cd7acf
 {
cd7acf
-    struct bootp_t *bp = mtod(m, struct bootp_t *);
cd7acf
+    struct bootp_t *bp = mtod_check(m, sizeof(struct bootp_t));
cd7acf
 
cd7acf
-    if (bp->bp_op == BOOTP_REQUEST) {
cd7acf
+    if (bp && bp->bp_op == BOOTP_REQUEST) {
cd7acf
         bootp_reply(m->slirp, bp, m_end(m));
cd7acf
     }
cd7acf
 }
cd7acf
-- 
cd7acf
2.29.0
cd7acf