stun

simple point to point tunnel
git clone git://git.2f30.org/stun.git
Log | Files | Refs | README

commit 4bbb3dc4bea9a44bcd868d8460e3b7e54d115d99
parent 30287437842e19234989ef96b0cbb8f203e62255
Author: sin <sin@2f30.org>
Date:   Sat Apr 30 16:22:43 +0100

Print an error message if packet is too large

Diffstat:
netpkt.c | 8++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/netpkt.c b/netpkt.c @@ -48,8 +48,10 @@ netwrite(int fd, unsigned char *pt, size_t ptlen, size_t *outlen) size_t buflen = noncelen + HDRLEN + ptlen + taglen; int n, total = 0; - if (buflen > maxbuflen) + if (buflen > maxbuflen) { + logerrx("packet is too large"); return PKTFAILED; + } arc4random_buf(wbuf, noncelen); pack16(&wbuf[noncelen], ptlen); @@ -83,8 +85,10 @@ netread(int fd, unsigned char *pt, size_t ptlen, size_t *outlen) size_t buflen = noncelen + HDRLEN + ptlen + taglen; int n, ctlen; - if (buflen > maxbuflen) + if (buflen > maxbuflen) { + logerrx("packet is too large"); return PKTFAILED; + } for (;;) { switch (state) {