thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone
c461a1
From dea2f95979cc0ba0c36f07b8e9cc709bd1ef1eb4 Mon Sep 17 00:00:00 2001
c461a1
From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= <philmd@redhat.com>
c461a1
Date: Fri, 17 Jan 2020 12:00:35 +0100
c461a1
Subject: [PATCH 1/3] tcp_emu: Fix oob access
c461a1
MIME-Version: 1.0
c461a1
Content-Type: text/plain; charset=UTF-8
c461a1
Content-Transfer-Encoding: 8bit
c461a1
c461a1
RH-Author: Philippe Mathieu-Daudé <philmd@redhat.com>
c461a1
Message-id: <20200117120037.12800-2-philmd@redhat.com>
c461a1
Patchwork-id: 93395
c461a1
O-Subject: [RHEL-7.7.z qemu-kvm + RHEL-7.8 qemu-kvm + RHEL-7.9 qemu-kvm PATCH v2 1/3] tcp_emu: Fix oob access
c461a1
Bugzilla: 1791560
c461a1
RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
c461a1
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
c461a1
RH-Acked-by: Thomas Huth <thuth@redhat.com>
c461a1
c461a1
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
c461a1
c461a1
The main loop only checks for one available byte, while we sometimes
c461a1
need two bytes.
c461a1
c461a1
(cherry picked from libslirp commit 2655fffed7a9e765bcb4701dd876e9dab975f289)
c461a1
[PMD: backported with style conflicts,
c461a1
      CHANGELOG.md absent in downstream]
c461a1
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
c461a1
c461a1
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
c461a1
---
c461a1
 slirp/tcp_subr.c | 7 +++++++
c461a1
 1 file changed, 7 insertions(+)
c461a1
c461a1
diff --git a/slirp/tcp_subr.c b/slirp/tcp_subr.c
c461a1
index d49a366..70a4c83 100644
c461a1
--- a/slirp/tcp_subr.c
c461a1
+++ b/slirp/tcp_subr.c
c461a1
@@ -837,6 +837,9 @@ tcp_emu(struct socket *so, struct mbuf *m)
c461a1
 				break;
c461a1
 
c461a1
 			 case 5:
c461a1
+				if (bptr == m->m_data + m->m_len - 1)
c461a1
+					return 1; /* We need two bytes */
c461a1
+
c461a1
 				/*
c461a1
 				 * The difference between versions 1.0 and
c461a1
 				 * 2.0 is here. For future versions of
c461a1
@@ -852,6 +855,10 @@ tcp_emu(struct socket *so, struct mbuf *m)
c461a1
 				/* This is the field containing the port
c461a1
 				 * number that RA-player is listening to.
c461a1
 				 */
c461a1
+
c461a1
+				if (bptr == m->m_data + m->m_len - 1)
c461a1
+					return 1; /* We need two bytes */
c461a1
+
c461a1
 				lport = (((u_char*)bptr)[0] << 8)
c461a1
 				+ ((u_char *)bptr)[1];
c461a1
 				if (lport < 6970)
c461a1
-- 
c461a1
1.8.3.1
c461a1