|
|
8b1478 |
From 6d692d3045b7102db2a64ea95d040b1fa6277433 Mon Sep 17 00:00:00 2001
|
|
|
8b1478 |
From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= <philmd@redhat.com>
|
|
|
8b1478 |
Date: Fri, 17 Jan 2020 11:49:42 +0100
|
|
|
8b1478 |
Subject: [PATCH 3/3] slirp: use correct size while emulating commands
|
|
|
8b1478 |
MIME-Version: 1.0
|
|
|
8b1478 |
Content-Type: text/plain; charset=UTF-8
|
|
|
8b1478 |
Content-Transfer-Encoding: 8bit
|
|
|
8b1478 |
|
|
|
8b1478 |
RH-Author: Philippe Mathieu-Daudé <philmd@redhat.com>
|
|
|
8b1478 |
Message-id: <20200117114942.12236-4-philmd@redhat.com>
|
|
|
8b1478 |
Patchwork-id: 93391
|
|
|
8b1478 |
O-Subject: [RHEL-7.7.z qemu-kvm-rhev + RHEL-7.8 qemu-kvm-rhev + RHEL-7.9 qemu-kvm-rhev + RHEL-8.1.0 qemu-kvm + RHEL-8.2.0 qemu-kvm + RHEL-7.7.z qemu-kvm-ma + RHEL-7.8 qemu-kvm-ma + RHEL-7.9 qemu-kvm-ma PATCH 3/3] slirp: use correct size while emulating commands
|
|
|
8b1478 |
Bugzilla: 1791563 1791570
|
|
|
8b1478 |
RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
|
|
|
8b1478 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
8b1478 |
RH-Acked-by: Thomas Huth <thuth@redhat.com>
|
|
|
8b1478 |
|
|
|
8b1478 |
From: Prasad J Pandit <pjp@fedoraproject.org>
|
|
|
8b1478 |
|
|
|
8b1478 |
While emulating services in tcp_emu(), it uses 'mbuf' size
|
|
|
8b1478 |
'm->m_size' to write commands via snprintf(3). Use M_FREEROOM(m)
|
|
|
8b1478 |
size to avoid possible OOB access.
|
|
|
8b1478 |
|
|
|
8b1478 |
Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
|
|
|
8b1478 |
Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
|
|
|
8b1478 |
Message-Id: <20200109094228.79764-3-ppandit@redhat.com>
|
|
|
8b1478 |
(cherry picked from libslirp commit 82ebe9c370a0e2970fb5695aa19aa5214a6a1c80)
|
|
|
8b1478 |
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
|
|
|
8b1478 |
|
|
|
8b1478 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
8b1478 |
---
|
|
|
8b1478 |
slirp/tcp_subr.c | 8 ++++----
|
|
|
8b1478 |
1 file changed, 4 insertions(+), 4 deletions(-)
|
|
|
8b1478 |
|
|
|
8b1478 |
diff --git a/slirp/tcp_subr.c b/slirp/tcp_subr.c
|
|
|
8b1478 |
index b60310d..b95ba23 100644
|
|
|
8b1478 |
--- a/slirp/tcp_subr.c
|
|
|
8b1478 |
+++ b/slirp/tcp_subr.c
|
|
|
8b1478 |
@@ -703,7 +703,7 @@ tcp_emu(struct socket *so, struct mbuf *m)
|
|
|
8b1478 |
n4 = (laddr & 0xff);
|
|
|
8b1478 |
|
|
|
8b1478 |
m->m_len = bptr - m->m_data; /* Adjust length */
|
|
|
8b1478 |
- m->m_len += snprintf(bptr, m->m_size - m->m_len,
|
|
|
8b1478 |
+ m->m_len += snprintf(bptr, M_FREEROOM(m),
|
|
|
8b1478 |
"ORT %d,%d,%d,%d,%d,%d\r\n%s",
|
|
|
8b1478 |
n1, n2, n3, n4, n5, n6, x==7?buff:"");
|
|
|
8b1478 |
return 1;
|
|
|
8b1478 |
@@ -736,7 +736,7 @@ tcp_emu(struct socket *so, struct mbuf *m)
|
|
|
8b1478 |
n4 = (laddr & 0xff);
|
|
|
8b1478 |
|
|
|
8b1478 |
m->m_len = bptr - m->m_data; /* Adjust length */
|
|
|
8b1478 |
- m->m_len += snprintf(bptr, m->m_size - m->m_len,
|
|
|
8b1478 |
+ m->m_len += snprintf(bptr, M_FREEROOM(m),
|
|
|
8b1478 |
"27 Entering Passive Mode (%d,%d,%d,%d,%d,%d)\r\n%s",
|
|
|
8b1478 |
n1, n2, n3, n4, n5, n6, x==7?buff:"");
|
|
|
8b1478 |
|
|
|
8b1478 |
@@ -762,8 +762,8 @@ tcp_emu(struct socket *so, struct mbuf *m)
|
|
|
8b1478 |
if (m->m_data[m->m_len-1] == '\0' && lport != 0 &&
|
|
|
8b1478 |
(so = tcp_listen(slirp, INADDR_ANY, 0, so->so_laddr.s_addr,
|
|
|
8b1478 |
htons(lport), SS_FACCEPTONCE)) != NULL)
|
|
|
8b1478 |
- m->m_len = snprintf(m->m_data, m->m_size, "%d",
|
|
|
8b1478 |
- ntohs(so->so_fport)) + 1;
|
|
|
8b1478 |
+ m->m_len = snprintf(m->m_data, M_ROOM(m),
|
|
|
8b1478 |
+ "%d", ntohs(so->so_fport)) + 1;
|
|
|
8b1478 |
return 1;
|
|
|
8b1478 |
|
|
|
8b1478 |
case EMU_IRC:
|
|
|
8b1478 |
--
|
|
|
8b1478 |
1.8.3.1
|
|
|
8b1478 |
|