chiark / gitweb /
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 b84c98b2e16abe7d2dec9c41fb06d1d60cb22a87..665b80ea7753ae99052046bff01935c230c43585 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 7394aaaa53456fd7590c4f83c94d536ad5d9d4cf..3686b7ba4e4691ee73fabb3a8f22b97a3a16b23d 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 6773ee64032dbef020eafe146830e7665e5653cc..b945c7dd92ecfd57afdf2c8a42d6436047c667e5 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 2794ca8ccb11d063137ccbc7fa4d409c7350f8a4..33451746fd9ff9adbff726f5d06ca0d299c9764e 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 11f9b67bc3baccab388c6f70b97efe2e1c6b65c9..719830bf113acae1dca79dd4286874b2aa91af89 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@ --- *