From 29dfa482aa5c461228706ad3ced42a652dab925b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Zden=C4=9Bk=20=C5=A0ustr?= Date: Wed, 25 May 2011 11:32:30 +0000 Subject: [PATCH] Throw error for HTTP requests longer than allocated buffer. (The error is not handled properly, yet. Connection just times out) --- org.glite.lb.common/src/mini_http.c | 10 +++++++++- org.glite.lb.server/src/bkserverd.c | 1 - 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/org.glite.lb.common/src/mini_http.c b/org.glite.lb.common/src/mini_http.c index 0788cdf..8697fb6 100644 --- a/org.glite.lb.common/src/mini_http.c +++ b/org.glite.lb.common/src/mini_http.c @@ -86,6 +86,14 @@ edg_wll_ErrorCode edg_wll_http_recv(edg_wll_Context ctx,char **firstOut,char *** connPTR->bufUse += len; rdmore = 0; + if (connPTR->bufUse >= connPTR->bufSize) { + edg_wll_SetError(ctx,EINVAL,"HTTP Request too long"); + free(connPTR->buf); connPTR->buf = NULL; + connPTR->bufUse = 0; + connPTR->bufSize = 0; + goto error; + } + while (!rdmore && pstat != DONE) switch (pstat) { char *cr; @@ -181,7 +189,7 @@ edg_wll_ErrorCode edg_wll_http_recv_proxy(edg_wll_Context ctx,char **firstOut,ch if ( !ctx->connProxy->buf ) { ctx->connProxy->bufSize = BUFSIZ; ctx->connProxy->bufUse = 0; - ctx->connProxy->buf = malloc(BUFSIZ); + ctx->connProxy->buf = malloc(ctx->connProxy->bufSize); } do { diff --git a/org.glite.lb.server/src/bkserverd.c b/org.glite.lb.server/src/bkserverd.c index abc2ac3..d5d81b4 100644 --- a/org.glite.lb.server/src/bkserverd.c +++ b/org.glite.lb.server/src/bkserverd.c @@ -1447,7 +1447,6 @@ static int handle_server_error(edg_wll_Context ctx) int err,ret = 0; - errt = errd = NULL; switch ( (err = edg_wll_Error(ctx, &errt, &errd)) ) { case ETIMEDOUT: -- 1.8.2.3