Various C files: Ignore write errors of UDP and IP datagrams.
authorMark Wooding <mdw@distorted.org.uk>
Sat, 22 May 2010 11:42:46 +0000 (12:42 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Sat, 22 May 2010 11:44:25 +0000 (12:44 +0100)
These packets are expected to go missing periodically and everyone will
cope.  Unfortunately, GCC wants us to do something with the return code
from write(2), so we explicitly assign it to a write-only variable and
hope that its data-flow analysis is done after it checks for return-code
ignoring.

pkstream/pkstream.c
proxy/tripe-mitm.c
server/tun-bsd.c
server/tun-linux.c
server/tun-unet.c

index b84c98b..665b80e 100644 (file)
@@ -120,6 +120,7 @@ static void rdtcp(octet *b, size_t sz, pkbuf *pk, size_t *k, void *vp)
 {
   pkstream *p = vp;
   size_t pksz;
+  int hunoz;
 
   if (!sz) {
     doclose(p);
@@ -127,7 +128,7 @@ static void rdtcp(octet *b, size_t sz, pkbuf *pk, size_t *k, void *vp)
   }
   pksz = LOAD16(b);
   if (pksz + 2 == sz) {
-    write(fd_udp, b + 2, pksz);
+    hunoz = write(fd_udp, b + 2, pksz);
     selpk_want(&p->p, 2);
   } else {
     selpk_want(&p->p, pksz + 2);
index 7394aaa..3686b7b 100644 (file)
@@ -406,8 +406,10 @@ static void adddelay(filter *f, unsigned ac, char **av)
 
 static void dosend(filter *f, const octet *buf, size_t sz)
 {
+  int hunoz;
+
   printf("send to `%s'\n", f->p_to->name);
-  write(f->p_to->sf.fd, buf, sz);
+  hunoz = write(f->p_to->sf.fd, buf, sz);
 }
 
 static void addsend(filter *f, unsigned ac, char **av)
index 6773ee6..b945c7d 100644 (file)
@@ -119,11 +119,13 @@ static tunnel *t_create(peer *p, int fd, char **ifn)
 
 static void t_inject(tunnel *t, buf *b)
 {
+  int hunoz;
+
   IF_TRACING(T_TUNNEL, {
     trace(T_TUNNEL, "tun-bsd: inject decrypted packet");
     trace_block(T_PACKET, "tun-bsd: packet contents", BBASE(b), BLEN(b));
   })
-  write(t->f.fd, BBASE(b), BLEN(b));
+  hunoz = write(t->f.fd, BBASE(b), BLEN(b));
 }
 
 /* --- @t_destroy@ --- *
index 2794ca8..3345174 100644 (file)
@@ -125,11 +125,13 @@ static tunnel *t_create(peer *p, int fd, char **ifn)
 
 static void t_inject(tunnel *t, buf *b)
 {
+  int hunoz;
+
   IF_TRACING(T_TUNNEL, {
     trace(T_TUNNEL, "tun-linux: inject decrypted packet");
     trace_block(T_PACKET, "tunnel: packet contents", BBASE(b), BLEN(b));
   })
-  write(t->f.fd, BBASE(b), BLEN(b));
+  hunoz = write(t->f.fd, BBASE(b), BLEN(b));
 }
 
 /* --- @t_destroy@ --- *
index 11f9b67..719830b 100644 (file)
@@ -125,11 +125,13 @@ static tunnel *t_create(peer *p, int fd, char **ifn)
 
 static void t_inject(tunnel *t, buf *b)
 {
+  int hunoz;
+
   IF_TRACING(T_TUNNEL, {
     trace(T_TUNNEL, "tun-unet: inject decrypted packet");
     trace_block(T_PACKET, "tun-unet: packet contents", BBASE(b), BLEN(b));
   })
-  write(t->f.fd, BBASE(b), BLEN(b));
+  hunoz = write(t->f.fd, BBASE(b), BLEN(b));
 }
 
 /* --- @t_destroy@ --- *