From 013f795cb54d42e6b057689f7d51fd27e1730197 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Tue, 2 Apr 2019 13:39:01 +0200 Subject: [PATCH 3/3] slirp: check sscanf result when emulating ident MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit RH-Author: Marc-André Lureau Message-id: <20190402133901.28238-1-marcandre.lureau@redhat.com> Patchwork-id: 85305 O-Subject: [RHEL-7.7 qemu-kvm PATCH] slirp: check sscanf result when emulating ident Bugzilla: 1689791 RH-Acked-by: Philippe Mathieu-Daudé RH-Acked-by: Markus Armbruster RH-Acked-by: Dr. David Alan Gilbert From: William Bowling When emulating ident in tcp_emu, if the strchr checks passed but the sscanf check failed, two uninitialized variables would be copied and sent in the reply, so move this code inside the if(sscanf()) clause. Signed-off-by: William Bowling Cc: qemu-stable@nongnu.org Cc: secalert@redhat.com Message-Id: <1551476756-25749-1-git-send-email-will@wbowling.info> Signed-off-by: Samuel Thibault Reviewed-by: Philippe Mathieu-Daudé (cherry picked from commit d3222975c7d6cda9e25809dea05241188457b113) Signed-off-by: Marc-André Lureau Signed-off-by: Miroslav Rezanina --- slirp/tcp_subr.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/slirp/tcp_subr.c b/slirp/tcp_subr.c index 043f28f..0b7138b 100644 --- a/slirp/tcp_subr.c +++ b/slirp/tcp_subr.c @@ -605,12 +605,12 @@ tcp_emu(struct socket *so, struct mbuf *m) break; } } + so_rcv->sb_cc = snprintf(so_rcv->sb_data, + so_rcv->sb_datalen, + "%d,%d\r\n", n1, n2); + so_rcv->sb_rptr = so_rcv->sb_data; + so_rcv->sb_wptr = so_rcv->sb_data + so_rcv->sb_cc; } - so_rcv->sb_cc = snprintf(so_rcv->sb_data, - so_rcv->sb_datalen, - "%d,%d\r\n", n1, n2); - so_rcv->sb_rptr = so_rcv->sb_data; - so_rcv->sb_wptr = so_rcv->sb_data + so_rcv->sb_cc; } m_free(m); return 0; -- 1.8.3.1