stun

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

commit fb4afdaecb88ac6d33cc09dee5ff7a3c5e0944a9
parent bff87543f1b85dd52ef94a8383495977d73b29f9
Author: sin <sin@2f30.org>
Date:   Tue, 12 Apr 2016 15:41:07 +0100

don't reuse n for random stuff

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

diff --git a/netpkt.c b/netpkt.c @@ -83,7 +83,7 @@ netwrite(int fd, unsigned char *pt, size_t ptlen, size_t *outlen) int netread(int fd, unsigned char *pt, size_t ptlen, size_t *outlen) { - int n; + int n, ctlen; for (;;) { switch (state) { @@ -108,11 +108,11 @@ netread(int fd, unsigned char *pt, size_t ptlen, size_t *outlen) rbuftotal += n; rbufrem -= n; if (rbufrem == 0) { - n = unpack16(&rbuf[noncelen]); - if (n > ptlen) { + ctlen = unpack16(&rbuf[noncelen]); + if (ctlen > ptlen) { state = STATEDISCARD; } else { - rbufrem = n; + rbufrem = ctlen; state = STATEPAYLOAD; } }