From 3fe0fc3a60fc3f29ee40b8474192a585a5eeaaa0 Mon Sep 17 00:00:00 2001 Message-Id: <3fe0fc3a60fc3f29ee40b8474192a585a5eeaaa0.1713455916.git.mdw@distorted.org.uk> From: Mark Wooding Date: Sat, 22 May 2010 12:42:46 +0100 Subject: [PATCH] Various C files: Ignore write errors of UDP and IP datagrams. Organization: Straylight/Edgeware From: Mark Wooding 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 | 3 ++- proxy/tripe-mitm.c | 4 +++- server/tun-bsd.c | 4 +++- server/tun-linux.c | 4 +++- server/tun-unet.c | 4 +++- 5 files changed, 14 insertions(+), 5 deletions(-) diff --git a/pkstream/pkstream.c b/pkstream/pkstream.c index b84c98b2..665b80ea 100644 --- a/pkstream/pkstream.c +++ b/pkstream/pkstream.c @@ -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); diff --git a/proxy/tripe-mitm.c b/proxy/tripe-mitm.c index 7394aaaa..3686b7ba 100644 --- a/proxy/tripe-mitm.c +++ b/proxy/tripe-mitm.c @@ -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) diff --git a/server/tun-bsd.c b/server/tun-bsd.c index 6773ee64..b945c7dd 100644 --- a/server/tun-bsd.c +++ b/server/tun-bsd.c @@ -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@ --- * diff --git a/server/tun-linux.c b/server/tun-linux.c index 2794ca8c..33451746 100644 --- a/server/tun-linux.c +++ b/server/tun-linux.c @@ -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@ --- * diff --git a/server/tun-unet.c b/server/tun-unet.c index 11f9b67b..719830bf 100644 --- a/server/tun-unet.c +++ b/server/tun-unet.c @@ -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@ --- * -- [mdw]