From 43f903ce5f313983fca91a96f786730cf8c8c645 Mon Sep 17 00:00:00 2001 From: "David S. Miller" Date: Thu, 18 Oct 2007 18:47:05 +0200 Subject: [PATCH] [NET]: Zero length write() on socket should not simply return 0. This fixes kernel bugzilla #5731 It should generate an empty packet for datagram protocols when the socket is connected, for one. The check is doubly-wrong because all that a write() can be is a sendmsg() call with a NULL msg_control and a single entry iovec. No special semantics should be assigned to it, therefore the zero length check should be removed entirely. This matches the behavior of BSD and several other systems. Alan Cox notes that SuSv3 says the behavior of a zero length write on non-files is "unspecified", but that's kind of useless since BSD has defined this behavior for a quarter century and BSD is essentially what application folks code to. Based upon a patch from Stephen Hemminger. Adrian Bunk: Backported to 2.6.16. Signed-off-by: David S. Miller Signed-off-by: Adrian Bunk --- net/socket.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/net/socket.c b/net/socket.c index a00851f981dbf..1230704cd9ca9 100644 --- a/net/socket.c +++ b/net/socket.c @@ -775,8 +775,6 @@ static ssize_t sock_aio_write(struct kiocb *iocb, const char __user *ubuf, if (pos != 0) return -ESPIPE; - if (count == 0) /* Match SYS5 behaviour */ - return 0; x = alloc_sock_iocb(iocb, (void __user *)ubuf, count, &siocb); if (!x) -- 2.47.2