03fb49
From 0f017f39a390d8fa4ae817f45fbf71a0c8332860 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:15:14 +0400
03fb49
Subject: [PATCH 3/7] bootp: check bootp_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-3592
03fb49
Fixes: https://gitlab.freedesktop.org/slirp/libslirp/-/issues/44
03fb49
03fb49
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
03fb49
(cherry picked from commit 2eca0838eee1da96204545e22cdaed860d9d7c6c)
03fb49
---
03fb49
 src/bootp.c | 4 ++--
03fb49
 1 file changed, 2 insertions(+), 2 deletions(-)
03fb49
03fb49
diff --git a/src/bootp.c b/src/bootp.c
03fb49
index e0db8d1..cafa1eb 100644
03fb49
--- a/src/bootp.c
03fb49
+++ b/src/bootp.c
03fb49
@@ -365,9 +365,9 @@ static void bootp_reply(Slirp *slirp,
03fb49
 
03fb49
 void bootp_input(struct mbuf *m)
03fb49
 {
03fb49
-    struct bootp_t *bp = mtod(m, struct bootp_t *);
03fb49
+    struct bootp_t *bp = mtod_check(m, sizeof(struct bootp_t));
03fb49
 
03fb49
-    if (bp->bp_op == BOOTP_REQUEST) {
03fb49
+    if (bp && bp->bp_op == BOOTP_REQUEST) {
03fb49
         bootp_reply(m->slirp, bp, m_end(m));
03fb49
     }
03fb49
 }
03fb49
-- 
03fb49
2.29.0
03fb49