X-Git-Url: https://tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Fmeta.c;h=849a0c6947a409807c396bf769c28567d5aa4360;hb=4d440336c3ce68719e23b2fc51fac368e23352ad;hp=ac937750b5933b90db4230a542a36cd477d9ab3d;hpb=8de8f1d9e2c2c02d4a14a5506e7d0d914dc328da;p=tinc diff --git a/src/meta.c b/src/meta.c index ac937750..849a0c69 100644 --- a/src/meta.c +++ b/src/meta.c @@ -85,6 +85,13 @@ bool receive_meta(connection_t *c) { - If not, keep stuff in buffer and exit. */ + buffer_compact(&c->inbuf, MAXBUFSIZE); + + if(sizeof inbuf <= c->inbuf.len) { + logger(LOG_ERR, "Input buffer full for %s (%s)", c->name, c->hostname); + return false; + } + inlen = recv(c->socket, inbuf, sizeof inbuf - c->inbuf.len, 0); if(inlen <= 0) { @@ -130,6 +137,7 @@ bool receive_meta(connection_t *c) { if(c->tcplen) { char *tcpbuffer = buffer_read(&c->inbuf, c->tcplen); if(tcpbuffer) { + c->tcplen = 0; receive_tcppacket(c, tcpbuffer, c->tcplen); continue; } else { @@ -151,7 +159,5 @@ bool receive_meta(connection_t *c) { } } while(inlen); - buffer_compact(&c->inbuf); - return true; }