File 0120-max_content_length.patch of Package sblim-sfcb
Index: control.c
===================================================================
RCS file: /cvsroot/sblim/sfcb/control.c,v
retrieving revision 1.24
diff -u -p -r1.24 control.c
--- control.c 5 Sep 2008 20:01:56 -0000 1.24
+++ control.c 16 Oct 2008 21:03:18 -0000
@@ -109,6 +109,7 @@ Control init[] = {
{"traceLevel", 1, "0"},
{"traceMask", 1, "0"},
+ {"httpMaxContentLength", 1, "0"},
};
void sunsetControl()
Index: httpAdapter.c
===================================================================
RCS file: /cvsroot/sblim/sfcb/httpAdapter.c,v
retrieving revision 1.61
diff -u -p -r1.61 httpAdapter.c
--- httpAdapter.c 15 Oct 2008 21:22:55 -0000 1.61
+++ httpAdapter.c 16 Oct 2008 21:03:18 -0000
@@ -779,6 +779,14 @@ static int doHttpRequest(CommHndl conn_f
cp = &hdr[15];
cp += strspn(cp, " \t");
inBuf.content_length = atol(cp);
+ int maxLen;
+ getControlNum("httpMaxContentLength", &maxLen);
+ if((maxLen) && (inBuf.content_length > maxLen)) {
+ genError(conn_fd, &inBuf, 413, "Request Entity Too Large", NULL);
+ _SFCB_TRACE(1, ("--- exiting: content-length too big"));
+ commClose(conn_fd);
+ exit(1);
+ }
}
else if (strncasecmp(hdr, "Content-Type:", 13) == 0) {
cp = &hdr[13];