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