warp-vpn

point to point VPN implementation
git clone git://git.2f30.org/warp-vpn
Log | Files | Refs | README

commit a53328fd9d16c4f1252b4082b314e6877b5a79d9
parent 7aa3b6b812e821c9b08fd6c2287290841a5c0262
Author: sin <sin@2f30.org>
Date:   Wed, 13 Apr 2016 09:52:07 +0100

add some buffer size checks

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

diff --git a/netpkt.c b/netpkt.c @@ -49,6 +49,9 @@ 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) + return PKTFAILED; + arc4random_buf(wbuf, noncelen); pack16(&wbuf[noncelen], ptlen); if (!cryptoseal(&wbuf[noncelen + HDRLEN], outlen, @@ -82,8 +85,12 @@ 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) { + size_t buflen = noncelen + HDRLEN + ptlen + taglen; int n, ctlen; + if (buflen > maxbuflen) + return PKTFAILED; + for (;;) { switch (state) { case INPUTINITIAL: