diff -N -c -r -X exclude_files squid-1.0.beta6/src/icp.c squid-1.0.beta6.henrik/src/icp.c *** squid-1.0.beta6/src/icp.c Fri May 3 02:11:13 1996 --- squid-1.0.beta6.henrik/src/icp.c Wed May 8 16:00:36 1996 *************** *** 1098,1103 **** --- 1098,1109 ---- int post_sz; int len; + /* Check that a complete line is received before parsing the request line */ + if (strchr(icpState->inbuf,'\n')==NULL) { + debug(12,5,"Incomplete request line, waiting for more data"); + return 0; + } + /* Use xmalloc/memcpy instead of xstrdup because inbuf might * contain NULL bytes; especially for POST data */ inbuf = (char *) xmalloc(icpState->offset + 1); *************** *** 1139,1144 **** --- 1145,1158 ---- req_hdr = t; req_hdr_sz = icpState->offset - (req_hdr - inbuf); + + /* The request is received when a empty header line is receied */ + if (!strstr(req_hdr, "\r\n\r\n") && !strstr(req_hdr, "\n\n")) { + xfree(inbuf); + return 0; /* not a complete request */ + } + + /* Ok, all headers are received */ icpState->request_hdr = (char *) xmalloc(req_hdr_sz + 1); memcpy(icpState->request_hdr, req_hdr, req_hdr_sz); *(icpState->request_hdr + req_hdr_sz) = '\0'; *************** *** 1154,1160 **** /* Expect Content-Length: and POST data after the headers */ if ((t = mime_get_header(req_hdr, "Content-Length")) == NULL) { xfree(inbuf); ! return 0; /* not a complete request */ } content_length = atoi(t); debug(12, 3, "parseHttpRequest: Expecting POST Content-Length of %d\n", --- 1168,1175 ---- /* Expect Content-Length: and POST data after the headers */ if ((t = mime_get_header(req_hdr, "Content-Length")) == NULL) { xfree(inbuf); ! debug(12,2,"POST without Content-Length\n"); ! return -1; } content_length = atoi(t); debug(12, 3, "parseHttpRequest: Expecting POST Content-Length of %d\n", *************** *** 1164,1169 **** --- 1179,1185 ---- } else if ((t = strstr(req_hdr, "\n\n"))) { post_data = t + 2; } else { + debug(12,1,"parseHttpRequest: This should not happen.. no panic\n"); xfree(inbuf); return 0; /* not a complete request */ } *************** *** 1174,1182 **** xfree(inbuf); return 0; } - } else if (!strstr(req_hdr, "\r\n\r\n") && !strstr(req_hdr, "\n\n")) { - xfree(inbuf); - return 0; /* not a complete request */ } /* Assign icpState->url */ if ((t = strchr(request, '\n'))) /* remove NL */ --- 1190,1195 ----