From nobody Tue Feb 10 07:22:36 2026 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.zohomail.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 1500121990144401.80962610769154; Sat, 15 Jul 2017 05:33:10 -0700 (PDT) Received: from localhost ([::1]:42005 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dWMFv-0006I8-0I for importer@patchew.org; Sat, 15 Jul 2017 08:33:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35850) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dWMDv-00059u-Vs for qemu-devel@nongnu.org; Sat, 15 Jul 2017 08:31:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dWMDv-00064g-3y for qemu-devel@nongnu.org; Sat, 15 Jul 2017 08:31:03 -0400 Received: from hera.aquilenet.fr ([2a01:474::1]:52266) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dWMDu-00064D-TJ for qemu-devel@nongnu.org; Sat, 15 Jul 2017 08:31:03 -0400 Received: from localhost (localhost [127.0.0.1]) by hera.aquilenet.fr (Postfix) with ESMTP id A69D7D725; Sat, 15 Jul 2017 14:31:02 +0200 (CEST) Received: from hera.aquilenet.fr ([127.0.0.1]) by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id iuSlyDBOlsRv; Sat, 15 Jul 2017 14:31:02 +0200 (CEST) Received: from var.youpi.perso.aquilenet.fr (unknown [IPv6:2a01:cb19:181:c200:3602:86ff:fe2c:6a19]) by hera.aquilenet.fr (Postfix) with ESMTPSA id 499D5D726; Sat, 15 Jul 2017 14:30:59 +0200 (CEST) Received: from samy by var.youpi.perso.aquilenet.fr with local (Exim 4.89) (envelope-from ) id 1dWMDq-0002EQ-HF; Sat, 15 Jul 2017 14:30:58 +0200 X-Virus-Scanned: Debian amavisd-new at aquilenet.fr From: Samuel Thibault To: qemu-devel@nongnu.org Date: Sat, 15 Jul 2017 14:30:57 +0200 Message-Id: <20170715123057.8529-5-samuel.thibault@ens-lyon.org> X-Mailer: git-send-email 2.13.2 In-Reply-To: <20170715123057.8529-1-samuel.thibault@ens-lyon.org> References: <20170715123057.8529-1-samuel.thibault@ens-lyon.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a01:474::1 Subject: [Qemu-devel] [PULL 4/4] 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: Peter Maydell , Samuel Thibault , stefanha@redhat.com, jan.kiszka@siemens.com 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" From: Peter Maydell 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 Signed-off-by: Samuel Thibault --- slirp/sbuf.c | 2 +- slirp/socket.c | 23 +++++++++++++++++------ 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/slirp/sbuf.c b/slirp/sbuf.c index 10119d3ad5..912f235f65 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 a17caa9fa7..ecec0295a9 100644 --- a/slirp/socket.c +++ b/slirp/socket.c @@ -404,7 +404,15 @@ sowrite(struct socket *so) DEBUG_ARG("so =3D %p", so); =20 if (so->so_urgc) { - sosendoob(so); + uint32_t expected =3D so->so_urgc; + if (sosendoob(so) < expected) { + /* 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 +456,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 +483,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.13.2