From 0476c0e2f495ee24ceb9dd871f445f09ccae1333 Mon Sep 17 00:00:00 2001 From: Olaf Hering Date: Sat, 6 Jan 2024 06:06:06 +0000 Subject: socket: consider write size of zero as error As a followup to bug#4726, handle a write size of zero for all transmission paths as error. This matches other parts of the code base, such as fd_write_all. Neither the gnutls nor the POSIX documentation mentions a write size of zero specifically. It is apparently up to each application to decide what to do with such short write results. So in case of Claws Mail, consider it an error in all cases. Signed-off-by: Olaf Hering --- src/common/socket.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/common/socket.c b/src/common/socket.c index 6e8bb745b..14f4cf5f0 100644 --- a/src/common/socket.c +++ b/src/common/socket.c @@ -1352,6 +1352,8 @@ gint sock_write(SockInfo *sock, const gchar *buf, gint len) #endif ret = fd_write(sock->sock, buf, len); + if (ret == 0) + ret = -1; if (ret < 0) sock->state = CONN_DISCONNECTED; return ret; base-commit: 41828b842604ac734bfba6c0669491d138c19c33