chiark / gitweb /
buffers: Introduce buf_remaining_space
[secnet.git] / tun.c
diff --git a/tun.c b/tun.c
index c511dbe23adb2ae510e70f8651fc269e8accbe3a..d4070f2ef405d7e8316bf23a84837189a05eddef 100644 (file)
--- a/tun.c
+++ b/tun.c
@@ -116,7 +116,7 @@ static void tun_afterpoll(void *sst, struct pollfd *fds, int nfds)
     if (fds[0].revents&POLLIN) {
        BUF_ALLOC(st->buff,"tun_afterpoll");
        buffer_init(st->buff,calculate_max_start_pad());
-       l=read(st->fd,st->buff->start,st->buff->len-calculate_max_start_pad());
+       l=read(st->fd, st->buff->start, buf_remaining_space(st->buff));
        if (l<0) {
            fatal_perror("tun_afterpoll: read()");
        }