cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-slirp-ensure-there-is-enough-space-in-mbuf-to-null-t.patch

4ec855
From ad30988fde29143951447e7f973918eaa09c448c Mon Sep 17 00:00:00 2001
4ec855
From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= <philmd@redhat.com>
4ec855
Date: Wed, 24 Jul 2019 15:53:36 +0100
4ec855
Subject: [PATCH 11/14] slirp: ensure there is enough space in mbuf to
4ec855
 null-terminate
4ec855
MIME-Version: 1.0
4ec855
Content-Type: text/plain; charset=UTF-8
4ec855
Content-Transfer-Encoding: 8bit
4ec855
4ec855
RH-Author: Philippe Mathieu-Daudé <philmd@redhat.com>
4ec855
Message-id: <20190724155337.25303-4-philmd@redhat.com>
4ec855
Patchwork-id: 89678
4ec855
O-Subject: [RHEL-8.1.0 qemu-kvm PATCH v2 3/4] slirp: ensure there is enough space in mbuf to null-terminate
4ec855
Bugzilla: 1727642
4ec855
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
4ec855
RH-Acked-by: Marc-André Lureau <marcandre.lureau@redhat.com>
4ec855
RH-Acked-by: Thomas Huth <thuth@redhat.com>
4ec855
4ec855
From: Marc-André Lureau <marcandre.lureau@redhat.com>
4ec855
4ec855
Prevents from buffer overflows.
4ec855
Related to: https://bugzilla.redhat.com/show_bug.cgi?id=1664205
4ec855
4ec855
Cc: Prasad J Pandit <pjp@fedoraproject.org>
4ec855
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
4ec855
4ec855
(cherry picked from libslirp commit
4ec855
306fef58b54d793ba4b259728c21322765bda917)
4ec855
4ec855
[ MA - backported with style conflicts fixes ]
4ec855
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
4ec855
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
4ec855
(cherry picked from commit e80c12dfdbde349dcd225771a4801b47be0b3b5f)
4ec855
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
4ec855
4ec855
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
4ec855
---
4ec855
 slirp/tcp_subr.c | 3 +++
4ec855
 1 file changed, 3 insertions(+)
4ec855
4ec855
diff --git a/slirp/tcp_subr.c b/slirp/tcp_subr.c
4ec855
index 393447d..e245e0d 100644
4ec855
--- a/slirp/tcp_subr.c
4ec855
+++ b/slirp/tcp_subr.c
4ec855
@@ -646,6 +646,7 @@ tcp_emu(struct socket *so, struct mbuf *m)
4ec855
 			memcpy(so_rcv->sb_wptr, m->m_data, m->m_len);
4ec855
 			so_rcv->sb_wptr += m->m_len;
4ec855
 			so_rcv->sb_rptr += m->m_len;
4ec855
+			m_inc(m, m->m_len + 1);
4ec855
 			m->m_data[m->m_len] = 0; /* NULL terminate */
4ec855
 			if (strchr(m->m_data, '\r') || strchr(m->m_data, '\n')) {
4ec855
 				if (sscanf(so_rcv->sb_data, "%u%*[ ,]%u", &n1, &n2) == 2) {
4ec855
@@ -679,6 +680,7 @@ tcp_emu(struct socket *so, struct mbuf *m)
4ec855
 		}
4ec855
 
4ec855
         case EMU_FTP: /* ftp */
4ec855
+		m_inc(m, m->m_len + 1);
4ec855
                 *(m->m_data+m->m_len) = 0; /* NUL terminate for strstr */
4ec855
 		if ((bptr = (char *)strstr(m->m_data, "ORT")) != NULL) {
4ec855
 			/*
4ec855
@@ -776,6 +778,7 @@ tcp_emu(struct socket *so, struct mbuf *m)
4ec855
 		/*
4ec855
 		 * Need to emulate DCC CHAT, DCC SEND and DCC MOVE
4ec855
 		 */
4ec855
+		m_inc(m, m->m_len + 1);
4ec855
 		*(m->m_data+m->m_len) = 0; /* NULL terminate the string for strstr */
4ec855
 		if ((bptr = (char *)strstr(m->m_data, "DCC")) == NULL)
4ec855
 			 return 1;
4ec855
-- 
4ec855
1.8.3.1
4ec855