chiark / gitweb /
autoconf: Provide an autogen.sh
[secnet.git] / udp.c
diff --git a/udp.c b/udp.c
index fa42ba43cfd0fb9672b8b2fcf5ba675320cd9594..bb82026c144d0df1f56f9f52e9401dd2fae91691 100644 (file)
--- a/udp.c
+++ b/udp.c
@@ -105,7 +105,7 @@ static void udp_afterpoll(void *state, struct pollfd *fds, int nfds)
            BUF_ALLOC(st->rbuf,"udp_afterpoll");
            buffer_init(st->rbuf,calculate_max_start_pad());
            rv=recvfrom(st->fd, st->rbuf->start,
-                       (st->rbuf->base + st->rbuf->len) - st->rbuf->start,
+                       buf_remaining_space(st->rbuf),
                        0, (struct sockaddr *)&from, &fromlen);
            if (rv>0) {
                st->rbuf->size=rv;
@@ -224,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;