--------------------- PatchSet 10439 Date: 2008/01/30 16:18:48 Author: adri Branch: s27_adri Tag: (none) Log: Correct off-by-one when assembling request header. Members: src/http.c:1.63.2.3.4.33->1.63.2.3.4.34 Index: squid/src/http.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/http.c,v retrieving revision 1.63.2.3.4.33 retrieving revision 1.63.2.3.4.34 diff -u -r1.63.2.3.4.33 -r1.63.2.3.4.34 --- squid/src/http.c 21 Jan 2008 03:50:24 -0000 1.63.2.3.4.33 +++ squid/src/http.c 30 Jan 2008 16:18:48 -0000 1.63.2.3.4.34 @@ -1,6 +1,6 @@ /* - * $Id: http.c,v 1.63.2.3.4.33 2008/01/21 03:50:24 adri Exp $ + * $Id: http.c,v 1.63.2.3.4.34 2008/01/30 16:18:48 adri Exp $ * * DEBUG: section 11 Hypertext Transfer Protocol (HTTP) * AUTHOR: Harvest Derived @@ -1206,8 +1206,13 @@ if (orig_request->port == urlDefaultPort(orig_request->protocol)) { httpHeaderPutStr(hdr_out, HDR_HOST, orig_request->host); } else { - httpHeaderPutStrf(hdr_out, HDR_HOST, "%s:%d", - orig_request->host, (int) orig_request->port); + String s; + stringLimitInit(&s, orig_request->host, strlen(orig_request->host)); + const char *p = xitoa((int) orig_request->port); + stringAppend(&s, ":", 1); + stringAppend(&s, p, strlen(p)); + httpHeaderPutString(hdr_out, HDR_HOST, s); + stringClean(&s); } } break; @@ -1436,11 +1441,18 @@ http_state_flags flags) { const int offset = mb->size; - memBufPrintf(mb, "%s %.*s HTTP/1.%d\r\n", - RequestMethods[request->method].str, - strLen2(request->urlpath) ? strLen2(request->urlpath) : 1, - strLen2(request->urlpath) ? strBuf2(request->urlpath) : "/", - flags.http11); + + memBufAppend(mb, RequestMethods[request->method].str, strlen(RequestMethods[request->method].str)); + memBufAppend(mb, " ", 1); + if (strLen2(request->urlpath) > 0) + memBufAppend(mb, strBuf2(request->urlpath), strLen2(request->urlpath)); + else + memBufAppend(mb, "/", 1); + if (flags.http11) + memBufAppend(mb, " HTTP/1.1\r\n", 11); + else + memBufAppend(mb, " HTTP/1.0\r\n", 11); + /* build and pack headers */ { HttpHeader hdr;