Fix zero length socket write() semantics.
commit791333baf11dbf37dd8f566909f8c1d5b939bf04
authorDavid S. Miller <davem@davemloft.net>
Wed, 10 Oct 2007 10:21:37 +0000 (10 03:21 -0700)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 2 Nov 2007 15:44:10 +0000 (2 08:44 -0700)
tree5ec9088b78ad051f2a58aa2d327e656604a4017a
parentf7c6bfbbb4a3c06015c2ce4098000a4d037098db
Fix zero length socket write() semantics.

changeset e79ad711a0108475c1b3a03815527e7237020b08 from mainline.

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.

Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
net/socket.c