From: P J P <ppandit@redhat.com>
To: QEMU Developers <qemu-devel@nongnu.org>
Cc: "Samuel Thibault" <samuel.thibault@ens-lyon.org>,
"Jason Wang" <jasowang@redhat.com>, Kira <864786842@qq.com>,
"Marc-André Lureau" <marcandre.lureau@gmail.com>,
"Jan Kiszka" <jan.kiszka@siemens.com>,
"Prasad J Pandit" <pjp@fedoraproject.org>
Subject: [Qemu-devel] [PATCH v2] slirp: check data length while emulating ident function
Date: Sun, 13 Jan 2019 23:29:48 +0530 [thread overview]
Message-ID: <20190113175948.21076-1-ppandit@redhat.com> (raw)
From: Prasad J Pandit <pjp@fedoraproject.org>
While emulating identification protocol, tcp_emu() does not check
available space in the 'sc_rcv->sb_data' buffer. It could lead to
heap buffer overflow issue. Add check to avoid it.
Reported-by: Kira <864786842@qq.com>
Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
---
slirp/tcp_subr.c | 4 ++++
1 file changed, 4 insertions(+)
Update v2: return 1 instead of 0
-> https://lists.gnu.org/archive/html/qemu-devel/2019-01/msg02182.html
diff --git a/slirp/tcp_subr.c b/slirp/tcp_subr.c
index fa61349cbb..8b1bd8c8c0 100644
--- a/slirp/tcp_subr.c
+++ b/slirp/tcp_subr.c
@@ -635,6 +635,10 @@ tcp_emu(struct socket *so, struct mbuf *m)
socklen_t addrlen = sizeof(struct sockaddr_in);
struct sbuf *so_rcv = &so->so_rcv;
+ if (m->m_len > so_rcv->sb_datalen
+ - (so_rcv->sb_wptr - so_rcv->sb_data)) {
+ return 1;
+ }
memcpy(so_rcv->sb_wptr, m->m_data, m->m_len);
so_rcv->sb_wptr += m->m_len;
so_rcv->sb_rptr += m->m_len;
--
2.20.1
next reply other threads:[~2019-01-13 18:02 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-13 17:59 P J P [this message]
2019-01-13 23:29 ` [Qemu-devel] [PATCH v2] slirp: check data length while emulating ident function Samuel Thibault
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190113175948.21076-1-ppandit@redhat.com \
--to=ppandit@redhat.com \
--cc=864786842@qq.com \
--cc=jan.kiszka@siemens.com \
--cc=jasowang@redhat.com \
--cc=marcandre.lureau@gmail.com \
--cc=pjp@fedoraproject.org \
--cc=qemu-devel@nongnu.org \
--cc=samuel.thibault@ens-lyon.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).