stun

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

commit 7110dfe51d3f9082d445f14e0cee73b9c22097ab
parent 2ef9f6169b348d7a5d71b58a4fb6f386f01df7f1
Author: sin <sin@2f30.org>
Date:   Wed, 30 Mar 2016 15:55:20 +0100

discard packets as early as possible

Diffstat:
Mstun.c | 8++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/stun.c b/stun.c @@ -477,10 +477,6 @@ readnet(int fd, unsigned char *pt, int len) pktlen = unpack16(hdr); pktlen &= PKTLENMASK; - n = readall(fd, iv, IVLEN); - if (n <= 0) - return n; - /* discard bad packets */ if (pktlen > sizeof(payload)) { while (pktlen) { @@ -496,6 +492,10 @@ readnet(int fd, unsigned char *pt, int len) return BADPKT; } + n = readall(fd, iv, IVLEN); + if (n <= 0) + return n; + n = readall(fd, payload, pktlen); if (n <= 0) return n;