X-Git-Url: https://git.distorted.org.uk/~mdw/secnet/blobdiff_plain/6af9a9842664ba88d89a67b300c1b0970bcf43ee..0f27325c8c760ab048600e36320551d1f4f22c97:/udp.c 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;