Throw error for HTTP requests longer than allocated buffer.
authorZdeněk Šustr <sustr4@cesnet.cz>
Wed, 25 May 2011 11:32:30 +0000 (11:32 +0000)
committerZdeněk Šustr <sustr4@cesnet.cz>
Wed, 25 May 2011 11:32:30 +0000 (11:32 +0000)
  (The error is not handled properly, yet. Connection just times out)

org.glite.lb.common/src/mini_http.c
org.glite.lb.server/src/bkserverd.c

index 0788cdf..8697fb6 100644 (file)
@@ -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 {
index abc2ac3..d5d81b4 100644 (file)
@@ -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: