bootp: check bootp_input buffer size
authorMarc-André Lureau <marcandre.lureau@redhat.com>
Fri, 4 Jun 2021 12:15:14 +0000 (16:15 +0400)
committerwanchao-xu <wanchao.xu@samsung.com>
Tue, 9 Jan 2024 12:02:33 +0000 (20:02 +0800)
Git-commit: 2eca0838eee1da96204545e22cdaed860d9d7c6c
References: bsc#1187364, CVE-2021-3592

Fixes: CVE-2021-3592
Fixes: https://gitlab.freedesktop.org/slirp/libslirp/-/issues/44
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Jose R Ziviani <jose.ziviani@suse.com>
slirp/src/bootp.c

index e0db8d19689490e179a95f57e4ddd0cec6d4b0b2..cafa1eb1f36ad010c36f2fbb343efce9caf1eeb7 100644 (file)
@@ -365,9 +365,9 @@ static void bootp_reply(Slirp *slirp,
 
 void bootp_input(struct mbuf *m)
 {
-    struct bootp_t *bp = mtod(m, struct bootp_t *);
+    struct bootp_t *bp = mtod_check(m, sizeof(struct bootp_t));
 
-    if (bp->bp_op == BOOTP_REQUEST) {
+    if (bp && bp->bp_op == BOOTP_REQUEST) {
         bootp_reply(m->slirp, bp, m_end(m));
     }
 }