* [Qemu-devel] [PATCH v2] slirp: check data length while emulating ident function
@ 2019-01-13 17:59 P J P
2019-01-13 23:29 ` Samuel Thibault
0 siblings, 1 reply; 2+ messages in thread
From: P J P @ 2019-01-13 17:59 UTC (permalink / raw)
To: QEMU Developers
Cc: Samuel Thibault, Jason Wang, Kira, Marc-André Lureau,
Jan Kiszka, Prasad J Pandit
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Qemu-devel] [PATCH v2] slirp: check data length while emulating ident function
2019-01-13 17:59 [Qemu-devel] [PATCH v2] slirp: check data length while emulating ident function P J P
@ 2019-01-13 23:29 ` Samuel Thibault
0 siblings, 0 replies; 2+ messages in thread
From: Samuel Thibault @ 2019-01-13 23:29 UTC (permalink / raw)
To: P J P
Cc: QEMU Developers, Jason Wang, Kira, Marc-André Lureau,
Jan Kiszka, Prasad J Pandit
P J P, le dim. 13 janv. 2019 23:29:48 +0530, a ecrit:
> 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>
Applied to my tree, thanks!
Samuel
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-01-13 23:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-01-13 17:59 [Qemu-devel] [PATCH v2] slirp: check data length while emulating ident function P J P
2019-01-13 23:29 ` Samuel Thibault
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).