From 90c7fafe594cf6d03c15a072a3d749f3e4d78482 Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Sun, 22 May 2011 12:56:51 +0200 Subject: [PATCH] Compact input buffer before trying to read instead of after. Also log an error when the input buffer contains more than MAXBUFSIZE bytes already, instead of silently claiming the other side closed the connection. --- src/meta.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/meta.c b/src/meta.c index ac937750..cf6b9d44 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); + + if(sizeof inbuf <= c->inbuf.len) { + logger(LOG_ERR, "Input buffer full for %s (%s)\n"); + return false; + } + inlen = recv(c->socket, inbuf, sizeof inbuf - c->inbuf.len, 0); if(inlen <= 0) { @@ -151,7 +158,5 @@ bool receive_meta(connection_t *c) { } } while(inlen); - buffer_compact(&c->inbuf); - return true; } -- 2.39.5