stun

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

commit 9f22bc0a15fc6bb6f61dde681e06500edc266696
parent 419684dcd9ed6ece9200c30438bffb9e9de855cd
Author: sin <sin@2f30.org>
Date:   Sun, 10 Apr 2016 12:38:03 +0100

some comments around readnet()

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

diff --git a/stun.c b/stun.c @@ -392,6 +392,12 @@ writenet(int fd, unsigned char *pt, int ptlen) return n; } +/* + * Read one complete packet off the network. If the payload + * length has been tampered with the tag will either not match + * or the read will timeout after RCVTIMEO ms. Timing out is + * necessary to make sure the two ends synchronize again. + */ int readnet(int fd, unsigned char *pt, int ptlen) { @@ -409,6 +415,7 @@ readnet(int fd, unsigned char *pt, int ptlen) goto err; if ((n = readall(fd, &pkt[noncelen], HDRLEN)) <= 0) goto err; + /* if payload len is bogus cap it */ if ((ctlen = unpack16(&pkt[noncelen])) > ptlen) ctlen = ptlen; if ((n = readall(fd, &pkt[noncelen + HDRLEN], ctlen + taglen)) <= 0)