stun

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

commit 750d344b045f486406e17d019e7572e8b00cae9a
parent c44fd2fe0c0c255909b3078f57a5057db8befc83
Author: sin <sin@2f30.org>
Date:   Wed,  6 Apr 2016 18:36:16 +0100

kill some impossible fatal errors and relax errors on seal

Diffstat:
Mstun.c | 14+++++---------
1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/stun.c b/stun.c @@ -385,8 +385,11 @@ writenet(int fd, unsigned char *pt, int ptlen) pack16(&pkt[noncelen], ptlen); if (!EVP_AEAD_CTX_seal(&ectx, &pkt[noncelen + HDRLEN], &outlen, ptlen + taglen, pkt, noncelen, - pt, ptlen, &pkt[noncelen], HDRLEN)) - logerr("EVP_AEAD_CTX_seal failed"); + pt, ptlen, &pkt[noncelen], HDRLEN)) { + free(pkt); + logwarn("EVP_AEAD_CTX_seal failed"); + return -1; + } n = writeall(fd, pkt, pktlen); free(pkt); return n; @@ -456,9 +459,6 @@ challenge(int netfd) return -1; } - if (pfd[0].revents & (POLLERR | POLLNVAL)) - logerr("bad fd in poll set"); - if (pfd[0].revents & (POLLIN | POLLHUP)) { ret = readnet(netfd, buf, sizeof(uint64_t)); if (ret <= 0 || ret == BADPKT) @@ -502,10 +502,6 @@ tunnel(int netfd, int devfd) if (poll(pfd, 2, -1) < 0) logerr("poll failed"); - if (pfd[0].revents & (POLLERR | POLLNVAL) || - pfd[1].revents & (POLLERR | POLLNVAL)) - logerr("bad fd in poll set"); - if (pfd[0].revents & (POLLIN | POLLHUP)) { n = readnet(netfd, buf, MAXPAYLOADLEN); if (n <= 0)