From nobody Wed Nov 5 18:27:46 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1496679820834399.34666974295317; Mon, 5 Jun 2017 09:23:40 -0700 (PDT) Received: from localhost ([::1]:34252 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dHun2-000174-Ii for importer@patchew.org; Mon, 05 Jun 2017 12:23:36 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43874) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dHujJ-0006R7-Bg for qemu-devel@nongnu.org; Mon, 05 Jun 2017 12:19:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dHujI-0000rZ-C0 for qemu-devel@nongnu.org; Mon, 05 Jun 2017 12:19:45 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:37196) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dHujI-0000nn-4Z for qemu-devel@nongnu.org; Mon, 05 Jun 2017 12:19:44 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.84_2) (envelope-from ) id 1dHujD-0002xA-A6; Mon, 05 Jun 2017 17:19:39 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Mon, 5 Jun 2017 17:19:36 +0100 Message-Id: <1496679576-14336-3-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1496679576-14336-1-git-send-email-peter.maydell@linaro.org> References: <1496679576-14336-1-git-send-email-peter.maydell@linaro.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:8b0:1d0::2 Subject: [Qemu-devel] [PATCH 2/2] slirp: Handle error returns from sosendoob() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Samuel Thibault , Jan Kiszka , patches@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" sosendoob() can return a failure code, but all its callers ignore it. This is OK in sbappend(), as the comment there states -- we will try again later in sowrite(). Add a (void) cast to tell Coverity so. In sowrite() we do need to check the return value -- we should handle a write failure in sosendoob() the same way we handle a write failure for the normal data. Signed-off-by: Peter Maydell Reviewed-by: Dr. David Alan Gilbert --- slirp/sbuf.c | 2 +- slirp/socket.c | 22 ++++++++++++++++------ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/slirp/sbuf.c b/slirp/sbuf.c index 10119d3..912f235 100644 --- a/slirp/sbuf.c +++ b/slirp/sbuf.c @@ -91,7 +91,7 @@ sbappend(struct socket *so, struct mbuf *m) if (so->so_urgc) { sbappendsb(&so->so_rcv, m); m_free(m); - sosendoob(so); + (void)sosendoob(so); return; } =20 diff --git a/slirp/socket.c b/slirp/socket.c index a17caa9..84cf13a 100644 --- a/slirp/socket.c +++ b/slirp/socket.c @@ -404,7 +404,14 @@ sowrite(struct socket *so) DEBUG_ARG("so =3D %p", so); =20 if (so->so_urgc) { - sosendoob(so); + if (sosendoob(so) < so->so_urgc) { + /* Treat a short write as a fatal error too, + * rather than continuing on and sending the urgent + * data as if it were non-urgent and leaving the + * so_urgc count wrong. + */ + goto err_disconnected; + } if (sb->sb_cc =3D=3D 0) return 0; } @@ -448,11 +455,7 @@ sowrite(struct socket *so) return 0; =20 if (nn <=3D 0) { - DEBUG_MISC((dfd, " --- sowrite disconnected, so->so_state =3D %x, errno = =3D %d\n", - so->so_state, errno)); - sofcantsendmore(so); - tcp_sockclosed(sototcpcb(so)); - return -1; + goto err_disconnected; } =20 #ifndef HAVE_READV @@ -479,6 +482,13 @@ sowrite(struct socket *so) sofcantsendmore(so); =20 return nn; + +err_disconnected: + DEBUG_MISC((dfd, " --- sowrite disconnected, so->so_state =3D %x, errno = =3D %d\n", + so->so_state, errno)); + sofcantsendmore(so); + tcp_sockclosed(sototcpcb(so)); + return -1; } =20 /* --=20 2.7.4