thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone
Blob Blame History Raw
From 5c2c5496083fa549e1dff903413bb6136fc19d8d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= <marcandre.lureau@redhat.com>
Date: Fri, 17 Jan 2020 12:07:56 +0100
Subject: [PATCH 1/4] tcp_emu: Fix oob access
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

RH-Author: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-id: <20200117120758.1076549-2-marcandre.lureau@redhat.com>
Patchwork-id: 93399
O-Subject: [RHEL-AV-8.1.0 qemu-kvm + RHEL-AV-8.2.0 qemu-kvm PATCH 1/3] tcp_emu: Fix oob access
Bugzilla: 1791568
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>

From: Samuel Thibault <samuel.thibault@ens-lyon.org>

The main loop only checks for one available byte, while we sometimes
need two bytes.

[ MA - minor conflict, CHANGELOG.md absent ]
(cherry picked from libslirp commit 2655fffed7a9e765bcb4701dd876e9dab975f289)
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>

Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
---
 slirp/src/tcp_subr.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/slirp/src/tcp_subr.c b/slirp/src/tcp_subr.c
index d6dd133..cbecd64 100644
--- a/slirp/src/tcp_subr.c
+++ b/slirp/src/tcp_subr.c
@@ -886,6 +886,9 @@ int tcp_emu(struct socket *so, struct mbuf *m)
                 break;
 
             case 5:
+                if (bptr == m->m_data + m->m_len - 1)
+                        return 1; /* We need two bytes */
+
                 /*
                  * The difference between versions 1.0 and
                  * 2.0 is here. For future versions of
@@ -901,6 +904,10 @@ int tcp_emu(struct socket *so, struct mbuf *m)
                 /* This is the field containing the port
                  * number that RA-player is listening to.
                  */
+
+                if (bptr == m->m_data + m->m_len - 1)
+                        return 1; /* We need two bytes */
+
                 lport = (((uint8_t *)bptr)[0] << 8) + ((uint8_t *)bptr)[1];
                 if (lport < 6970)
                     lport += 256; /* don't know why */
-- 
1.8.3.1