X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=secnet.git;a=blobdiff_plain;f=udp.c;h=bb82026c144d0df1f56f9f52e9401dd2fae91691;hp=1e637b6e5be7740ccb53f3678496298a8f31ffe2;hb=c7396710e7bf07f947ec6e8623144acff130d920;hpb=6af9a9842664ba88d89a67b300c1b0970bcf43ee diff --git a/udp.c b/udp.c index 1e637b6..bb82026 100644 --- a/udp.c +++ b/udp.c @@ -19,6 +19,7 @@ #include #include #include "util.h" +#include "magic.h" #include "unaligned.h" #include "ipaddr.h" #include "magic.h" @@ -103,8 +104,9 @@ static void udp_afterpoll(void *state, struct pollfd *fds, int nfds) BUF_ASSERT_FREE(st->rbuf); BUF_ALLOC(st->rbuf,"udp_afterpoll"); buffer_init(st->rbuf,calculate_max_start_pad()); - rv=recvfrom(st->fd, st->rbuf->start, st->rbuf->len, 0, - (struct sockaddr *)&from, &fromlen); + rv=recvfrom(st->fd, st->rbuf->start, + buf_remaining_space(st->rbuf), + 0, (struct sockaddr *)&from, &fromlen); if (rv>0) { st->rbuf->size=rv; if (st->use_proxy) { @@ -222,10 +224,7 @@ static void udp_phase_hook(void *sst, uint32_t new_phase) fatal_perror("udp (%s:%d): fcntl(set O_NONBLOCK)", st->loc.file,st->loc.line); } - if (fcntl(st->fd, F_SETFD, FD_CLOEXEC)==-1) { - fatal_perror("udp (%s:%d): fcntl(set FD_CLOEXEC)", - st->loc.file,st->loc.line); - } + setcloexec(st->fd); FILLZERO(addr); addr.sin_family=AF_INET;