diff options
author | Prasad J Pandit <pjp@fedoraproject.org> | 2019-01-13 23:29:48 +0530 |
---|---|---|
committer | Michael Roth <mdroth@linux.vnet.ibm.com> | 2019-04-02 13:16:34 -0500 |
commit | 345fab6ffe57b0bf6dccbc0844f45f77b91d9de0 (patch) | |
tree | a8cbcfe7568ac73539aec44b2bd3bee437dd2144 | |
parent | bd6dd4eaa6f7fe0c4d797d4e59803d295313b7a7 (diff) |
slirp: check data length while emulating ident function
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>
Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
(cherry picked from commit a7104eda7dab99d0cdbd3595c211864cba415905)
*CVE-2019-6778
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
-rw-r--r-- | slirp/tcp_subr.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/slirp/tcp_subr.c b/slirp/tcp_subr.c index 473c8b04e6..aa88de854a 100644 --- a/slirp/tcp_subr.c +++ b/slirp/tcp_subr.c @@ -640,6 +640,11 @@ 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; |