|
|
9ae3a8 |
From e80c12dfdbde349dcd225771a4801b47be0b3b5f Mon Sep 17 00:00:00 2001
|
|
|
9ae3a8 |
From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= <marcandre.lureau@redhat.com>
|
|
|
9ae3a8 |
Date: Mon, 20 May 2019 16:43:14 +0200
|
|
|
9ae3a8 |
Subject: [PATCH 3/4] slirp: ensure there is enough space in mbuf to
|
|
|
9ae3a8 |
null-terminate
|
|
|
9ae3a8 |
MIME-Version: 1.0
|
|
|
9ae3a8 |
Content-Type: text/plain; charset=UTF-8
|
|
|
9ae3a8 |
Content-Transfer-Encoding: 8bit
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
RH-Author: Marc-André Lureau <marcandre.lureau@redhat.com>
|
|
|
9ae3a8 |
Message-id: <20190520164315.22140-3-marcandre.lureau@redhat.com>
|
|
|
9ae3a8 |
Patchwork-id: 88094
|
|
|
9ae3a8 |
O-Subject: [RHEL-7.7 qemu-kvm PATCH 2/3] slirp: ensure there is enough space in mbuf to null-terminate
|
|
|
9ae3a8 |
Bugzilla: 1669068
|
|
|
9ae3a8 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Thomas Huth <thuth@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Prevents from buffer overflows.
|
|
|
9ae3a8 |
Related to: https://bugzilla.redhat.com/show_bug.cgi?id=1664205
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Cc: Prasad J Pandit <pjp@fedoraproject.org>
|
|
|
9ae3a8 |
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
(cherry picked from libslirp commit
|
|
|
9ae3a8 |
306fef58b54d793ba4b259728c21322765bda917)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
[ MA - backported with style conflicts fixes ]
|
|
|
9ae3a8 |
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
slirp/tcp_subr.c | 3 +++
|
|
|
9ae3a8 |
1 file changed, 3 insertions(+)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/slirp/tcp_subr.c b/slirp/tcp_subr.c
|
|
|
9ae3a8 |
index 80538a9..578b204 100644
|
|
|
9ae3a8 |
--- a/slirp/tcp_subr.c
|
|
|
9ae3a8 |
+++ b/slirp/tcp_subr.c
|
|
|
9ae3a8 |
@@ -586,6 +586,7 @@ tcp_emu(struct socket *so, struct mbuf *m)
|
|
|
9ae3a8 |
memcpy(so_rcv->sb_wptr, m->m_data, m->m_len);
|
|
|
9ae3a8 |
so_rcv->sb_wptr += m->m_len;
|
|
|
9ae3a8 |
so_rcv->sb_rptr += m->m_len;
|
|
|
9ae3a8 |
+ m_inc(m, m->m_len + 1);
|
|
|
9ae3a8 |
m->m_data[m->m_len] = 0; /* NULL terminate */
|
|
|
9ae3a8 |
if (strchr(m->m_data, '\r') || strchr(m->m_data, '\n')) {
|
|
|
9ae3a8 |
if (sscanf(so_rcv->sb_data, "%u%*[ ,]%u", &n1, &n2) == 2) {
|
|
|
9ae3a8 |
@@ -619,6 +620,7 @@ tcp_emu(struct socket *so, struct mbuf *m)
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
case EMU_FTP: /* ftp */
|
|
|
9ae3a8 |
+ m_inc(m, m->m_len + 1);
|
|
|
9ae3a8 |
*(m->m_data+m->m_len) = 0; /* NUL terminate for strstr */
|
|
|
9ae3a8 |
if ((bptr = (char *)strstr(m->m_data, "ORT")) != NULL) {
|
|
|
9ae3a8 |
/*
|
|
|
9ae3a8 |
@@ -716,6 +718,7 @@ tcp_emu(struct socket *so, struct mbuf *m)
|
|
|
9ae3a8 |
/*
|
|
|
9ae3a8 |
* Need to emulate DCC CHAT, DCC SEND and DCC MOVE
|
|
|
9ae3a8 |
*/
|
|
|
9ae3a8 |
+ m_inc(m, m->m_len + 1);
|
|
|
9ae3a8 |
*(m->m_data+m->m_len) = 0; /* NULL terminate the string for strstr */
|
|
|
9ae3a8 |
if ((bptr = (char *)strstr(m->m_data, "DCC")) == NULL)
|
|
|
9ae3a8 |
return 1;
|
|
|
9ae3a8 |
--
|
|
|
9ae3a8 |
1.8.3.1
|
|
|
9ae3a8 |
|