X-Git-Url: https://tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Fmeta.c;h=29dd824042754358bba1a0efaec4698b782e70b1;hb=2ba61742d4c2ab82525efb806dc654a6d95d335e;hp=1fbd22c29c26e90ccc11a85337598d6413c5f4f3;hpb=ffa3a443b9f01d3ea0fcb3c4fc6928a5c695cf4a;p=tinc diff --git a/src/meta.c b/src/meta.c index 1fbd22c2..29dd8240 100644 --- a/src/meta.c +++ b/src/meta.c @@ -72,7 +72,7 @@ void broadcast_meta(connection_t *from, const char *buffer, int length) { } bool receive_meta(connection_t *c) { - int inlen, reqlen; + int inlen; char inbuf[MAXBUFSIZE]; char *bufp = inbuf, *endp; @@ -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) { @@ -131,6 +138,7 @@ bool receive_meta(connection_t *c) { char *tcpbuffer = buffer_read(&c->inbuf, c->tcplen); if(tcpbuffer) { receive_tcppacket(c, tcpbuffer, c->tcplen); + c->tcplen = 0; continue; } else { break; @@ -151,7 +159,5 @@ bool receive_meta(connection_t *c) { } } while(inlen); - buffer_compact(&c->inbuf); - return true; }