X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?a=blobdiff_plain;ds=sidebyside;f=ipif%2Fservice.c;h=b9e40e29fcdb3a2f26ccabf02122d49ab230d388;hb=44a77f4851d3c819f9b364018a9695f332758a71;hp=1387d0e2c9c64e373707a5084e72941a1da4dccf;hpb=22410bfab3b25f35b15122a6c1d5e3efa7e3970a;p=userv-utils.git diff --git a/ipif/service.c b/ipif/service.c index 1387d0e..b9e40e2 100644 --- a/ipif/service.c +++ b/ipif/service.c @@ -48,9 +48,9 @@ * not supported). If no additional routes are to be set up, use `-' * or supply an empty argument. * - * Each item - whether a line file such as - * /etc/userv/ipif-networks, or supplied on the service program - * command line - is one of: + * Each item - whether a line in a file such as + * /etc/userv/ipif-networks, or the single trusted argument supplied + * on the service program command line - is one of: * * / * ./ @@ -719,11 +719,13 @@ static void setnonblock(int fd) { } static void rx_packet(const uint8_t *packet, int len) { + if (!len) + return; for (;;) { int r= write(tunfd, packet, len); if (r<0) { if (errno==EINTR) continue; - if (errno==EAGAIN) return; /* oh well */ + if (errno==EAGAIN || errno==ENOMEM) return; /* oh well */ sysfatal("error writing packet to tun (transmitting)"); } assert(r==len); @@ -861,7 +863,7 @@ static void copydata(void) { r= read(0, input_buf + input_waiting, want); if (r>0) { input_waiting += r; - assert(r < sizeof(input_buf)); + assert(input_waiting <= sizeof(input_buf)); more_rx_data(input_buf, rx_packet_buf); } else if (r==0) { terminate(0);