chiark / gitweb /
Merge branch 'master' of login.chiark.greenend.org.uk:/home/ian/public-git/userv...
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 27 Jan 2013 13:48:28 +0000 (13:48 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 27 Jan 2013 13:48:28 +0000 (13:48 +0000)
1  2 
ipif/service.c

diff --combined ipif/service.c
index 4c9b52463623a2a2437f6f5c0d318724f8f102af,87dac8e7544d46a7835e0b4a9591734f4e8ed55f..b9e40e29fcdb3a2f26ccabf02122d49ab230d388
@@@ -32,9 -32,9 +32,9 @@@
   *
   *  <local-addr>,<peer-addr>,<mtu>,<proto>
   *
 - *      As for slattach.  Supported protocols are slip, cslip, and
 - *      adaptive.  Alternatively, set to `debug' to print debugging info
 - *      and exit.  <local-addr> is address of the interface to be created
 + *      As for slattach.  The only supported protocol is slip.
 + *      Alternatively, set to `debug' to print debugging info and
 + *      exit.  <local-addr> is address of the interface to be created
   *      on the local system; <peer-addr> is the address of the
   *      point-to-point peer.  They must be actual addresses (not
   *      hostnames).
@@@ -48,9 -48,9 +48,9 @@@
   *      not supported).  If no additional routes are to be set up, use `-'
   *      or supply an empty argument.
   *
 - * Each <config> item - whether a line file such as
 - * /etc/userv/ipif-networks, or supplied on the service program
 - * command line - is one of:
 + * Each <config> 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:
   *
   *   /<config-file-name>
   *   ./<config-file-name>
@@@ -719,11 -719,13 +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 +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);