aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2017-07-14 12:12:25 +0100
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2017-07-15 14:28:25 +0200
commitdb0dd60b8c8de91ef3f6d66a2d0c2b62ab94c400 (patch)
tree9a2625ddd3a13e06c0d4dcdec9420db0e13953c6
parente8f9abd2efacdee175dc811b982234fd9aec28d5 (diff)
downloadslirp-db0dd60b8c8de91ef3f6d66a2d0c2b62ab94c400.zip
slirp-db0dd60b8c8de91ef3f6d66a2d0c2b62ab94c400.tar.gz
slirp-db0dd60b8c8de91ef3f6d66a2d0c2b62ab94c400.tar.bz2
slirp: Handle error returns from sosendoob()v2.10.0-rc1v2.10.0-rc0
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 <peter.maydell@linaro.org> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
-rw-r--r--sbuf.c2
-rw-r--r--socket.c25
2 files changed, 19 insertions, 8 deletions
diff --git a/sbuf.c b/sbuf.c
index 8a0a6a9..01f9a46 100644
--- a/sbuf.c
+++ b/sbuf.c
@@ -88,7 +88,7 @@ void 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;
}
diff --git a/socket.c b/socket.c
index 4151eb8..b346e1c 100644
--- a/socket.c
+++ b/socket.c
@@ -401,7 +401,15 @@ int sowrite(struct socket *so)
DEBUG_ARG("so = %p", so);
if (so->so_urgc) {
- sosendoob(so);
+ uint32_t expected = 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 == 0)
return 0;
}
@@ -448,12 +456,7 @@ int sowrite(struct socket *so)
return 0;
if (nn <= 0) {
- DEBUG_MISC(
- (dfd, " --- sowrite disconnected, so->so_state = %x, errno = %d\n",
- so->so_state, errno));
- sofcantsendmore(so);
- tcp_sockclosed(sototcpcb(so));
- return -1;
+ goto err_disconnected;
}
#ifndef HAVE_READV
@@ -480,6 +483,14 @@ int sowrite(struct socket *so)
sofcantsendmore(so);
return nn;
+
+err_disconnected:
+ DEBUG_MISC((dfd,
+ " --- sowrite disconnected, so->so_state = %x, errno = %d\n",
+ so->so_state, errno));
+ sofcantsendmore(so);
+ tcp_sockclosed(sototcpcb(so));
+ return -1;
}
/*