From 35e394684d9e505e2e0c8d1b4f5c7423376cbe5a Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 17 Feb 2010 13:53:02 +0100 Subject: [PATCH 1/3] tsocket/bsd: fix bug #7115 FreeBSD includes the UDP header in FIONREAD metze (cherry picked from commit d07cd37b993d3c9beded20323174633b806196b5) --- lib/tsocket/tsocket_bsd.c | 10 ++++++---- 1 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/tsocket/tsocket_bsd.c b/lib/tsocket/tsocket_bsd.c index 634deb8..8080d41 100644 --- a/lib/tsocket/tsocket_bsd.c +++ b/lib/tsocket/tsocket_bsd.c @@ -877,10 +877,12 @@ static void tdgram_bsd_recvfrom_handler(void *private_data) return; } - if (ret != state->len) { - tevent_req_error(req, EIO); - return; - } + /* + * some systems too much bytes in tsocket_bsd_pending() + * the return value includes some IP/UDP header bytes + */ + state->len = ret; + talloc_realloc(state, state->buf, uint8_t, ret); tevent_req_done(req); } -- 1.6.3.3 From 497e8c02749ac8ee8f80d4398390a3c0d110a1d4 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 17 Feb 2010 09:24:34 -0800 Subject: [PATCH 2/3] Fix commit d07cd37b993d3c9beded20323174633b806196b5 Which was: tsocket/bsd: fix bug #7115 FreeBSD includes the UDP header in FIONREAD Metze, this has to have been wrong - you are throwing away the talloc_realloc pointer returned. Also no error checking. Please review. Thank goodness for gcc warnings :-). Jeremy. (cherry picked from commit 936828de71023d90aaec6c1dba84052246bbad11) Signed-off-by: Stefan Metzmacher --- lib/tsocket/tsocket_bsd.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) diff --git a/lib/tsocket/tsocket_bsd.c b/lib/tsocket/tsocket_bsd.c index 8080d41..a0caa5a 100644 --- a/lib/tsocket/tsocket_bsd.c +++ b/lib/tsocket/tsocket_bsd.c @@ -881,8 +881,11 @@ static void tdgram_bsd_recvfrom_handler(void *private_data) * some systems too much bytes in tsocket_bsd_pending() * the return value includes some IP/UDP header bytes */ + state->buf = talloc_realloc(state, state->buf, uint8_t, ret); + if (tevent_req_nomem(state->buf, req)) { + return; + } state->len = ret; - talloc_realloc(state, state->buf, uint8_t, ret); tevent_req_done(req); } -- 1.6.3.3 From 26bc6c849603417cae897f19241ea7bcb38876cd Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 17 Feb 2010 19:11:11 +0100 Subject: [PATCH 3/3] tsocket/bsd: fix comment in tdgram_bsd_recvfrom_handler() metze (cherry picked from commit c42d9c4ec410e205091784cd97cbceb5572609d8) --- lib/tsocket/tsocket_bsd.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/tsocket/tsocket_bsd.c b/lib/tsocket/tsocket_bsd.c index a0caa5a..201788e 100644 --- a/lib/tsocket/tsocket_bsd.c +++ b/lib/tsocket/tsocket_bsd.c @@ -878,8 +878,10 @@ static void tdgram_bsd_recvfrom_handler(void *private_data) } /* - * some systems too much bytes in tsocket_bsd_pending() - * the return value includes some IP/UDP header bytes + * Some systems (FreeBSD, see bug #7115) return too much + * bytes in tsocket_bsd_pending()/ioctl(fd, FIONREAD, ...), + * the return value includes some IP/UDP header bytes, + * while recvfrom() just returns the payload. */ state->buf = talloc_realloc(state, state->buf, uint8_t, ret); if (tevent_req_nomem(state->buf, req)) { -- 1.6.3.3