lib/tsocket: fix receiving of udp packets from 0 bytes (bug #9184)
authorStefan Metzmacher <metze@samba.org>
Fri, 21 Sep 2012 20:54:26 +0000 (22:54 +0200)
committerStefan Metzmacher <metze@samba.org>
Sat, 22 Sep 2012 02:31:06 +0000 (04:31 +0200)
It's possible for a client to send 0 bytes in a UDP packet,
we need still need to call recvfrom() and skip the invalid
packet at a higher level. Otherwise the kernel receive queue
is blocked.

metze

lib/tsocket/tsocket_bsd.c

index 9e800652270db19de021c90b930212ae3b9006c6..d5721b4d94ef5d41c81215ec3efb0f120f92d97f 100644 (file)
@@ -876,10 +876,6 @@ static void tdgram_bsd_recvfrom_handler(void *private_data)
        bool retry;
 
        ret = tsocket_bsd_pending(bsds->fd);
-       if (ret == 0) {
-               /* retry later */
-               return;
-       }
        err = tsocket_bsd_error_from_errno(ret, errno, &retry);
        if (retry) {
                /* retry later */
@@ -889,6 +885,7 @@ static void tdgram_bsd_recvfrom_handler(void *private_data)
                return;
        }
 
+       /* note that 'ret' can be 0 here */
        state->buf = talloc_array(state, uint8_t, ret);
        if (tevent_req_nomem(state->buf, req)) {
                return;