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