--------------------- PatchSet 10283 Date: 2007/12/20 03:22:35 Author: adri Branch: s27_adri Tag: (none) Log: httpHeaderGetStr() purges - replace it with httpHeaderGetString() calls. This is about 2/3rds of the calls rewritten to use String. Members: ADRIAN_TODO:1.1.2.14->1.1.2.15 libhttp/HttpStrList.c:1.1.2.2->1.1.2.3 libhttp/HttpStrList.h:1.1.2.1->1.1.2.2 src/HttpHeader.c:1.28.6.1.4.20->1.28.6.1.4.21 src/HttpMsg.c:1.12->1.12.12.1 src/HttpRequest.c:1.17.10.1.4.4->1.17.10.1.4.5 src/client_side.c:1.202.2.9.4.17->1.202.2.9.4.18 src/errormap.c:1.4.12.1.4.1->1.4.12.1.4.2 src/http.c:1.63.2.3.4.14->1.63.2.3.4.15 src/locrewrite.c:1.4->1.4.54.1 src/protos.h:1.146.2.4.4.27->1.146.2.4.4.28 src/referer.c:1.7->1.7.8.1 src/structs.h:1.158.2.5.4.5->1.158.2.5.4.6 src/useragent.c:1.9->1.9.8.1 Index: squid/ADRIAN_TODO =================================================================== RCS file: /cvsroot/squid-sf//squid/Attic/ADRIAN_TODO,v retrieving revision 1.1.2.14 retrieving revision 1.1.2.15 diff -u -r1.1.2.14 -r1.1.2.15 --- squid/ADRIAN_TODO 19 Dec 2007 04:00:52 -0000 1.1.2.14 +++ squid/ADRIAN_TODO 20 Dec 2007 03:22:35 -0000 1.1.2.15 @@ -84,3 +84,7 @@ * src/http.c - the chunk header parsing section now uses a temp C nul terminated buffer and this really needs to go the heck away later on. + +* ARGH! All of the callers to httpHeaderGetStr() need to be modified; httpHeaderGetStr() + now returns a non-NUL-terminated buffer! + Index: squid/libhttp/HttpStrList.c =================================================================== RCS file: /cvsroot/squid-sf//squid/libhttp/Attic/HttpStrList.c,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -u -r1.1.2.2 -r1.1.2.3 --- squid/libhttp/HttpStrList.c 19 Dec 2007 16:14:31 -0000 1.1.2.2 +++ squid/libhttp/HttpStrList.c 20 Dec 2007 03:22:36 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* - * $Id: HttpStrList.c,v 1.1.2.2 2007/12/19 16:14:31 adri Exp $ + * $Id: HttpStrList.c,v 1.1.2.3 2007/12/20 03:22:36 adri Exp $ * * DEBUG: section 66 HTTP Header Tools * AUTHOR: Alex Rousskov @@ -55,8 +55,8 @@ extern const char *const w_space; /* " \t\n\r" */ /* returns true iff "m" is a member of the list */ -int -strListIsMemberStr(const String * list, const char *m, int mlen, char del) +static int +strListIsMemberInt(const String * list, const char *m, int mlen, char del) { strListItemIterator ipos = 0; const char *item; @@ -70,9 +70,15 @@ } int +strListIsMemberStr(const String * list, const String *m, char del) +{ + return strListIsMemberInt(list, strBuf2(*m), strLen2(*m), del); +} + +int strListIsMember(const String *list, const char *m, char del) { - return strListIsMemberStr(list, m, strlen(m), del); + return strListIsMemberInt(list, m, strlen(m), del); } /* returns true iff "s" is a substring of a member of the list, >1 if more than once */ @@ -81,6 +87,7 @@ { const char *p; assert(list && s); + assert(1==0); /* XXX fix this routine damnit! */ p = strStr(*list, s); if (!p) return 0; Index: squid/libhttp/HttpStrList.h =================================================================== RCS file: /cvsroot/squid-sf//squid/libhttp/Attic/HttpStrList.h,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -u -r1.1.2.1 -r1.1.2.2 --- squid/libhttp/HttpStrList.h 17 Dec 2007 08:17:47 -0000 1.1.2.1 +++ squid/libhttp/HttpStrList.h 20 Dec 2007 03:22:36 -0000 1.1.2.2 @@ -6,7 +6,7 @@ extern void strListAdd(String * str, const char *item, int len, char del); extern void strListAddUnique(String * str, const char *item, char del); extern int strListIsMember(const String * str, const char *item, char del); -extern int strListIsMemberStr(const String * str, const char *item, int len, char del); +extern int strListIsMemberStr(const String * str, const String *item, char del); extern int strIsSubstr(const String * list, const char *s); extern int strListGetItem(const String * str, char del, const char **item, int *ilen, strListItemIterator *ipos); Index: squid/src/HttpHeader.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/HttpHeader.c,v retrieving revision 1.28.6.1.4.20 retrieving revision 1.28.6.1.4.21 diff -u -r1.28.6.1.4.20 -r1.28.6.1.4.21 --- squid/src/HttpHeader.c 17 Dec 2007 08:17:48 -0000 1.28.6.1.4.20 +++ squid/src/HttpHeader.c 20 Dec 2007 03:22:36 -0000 1.28.6.1.4.21 @@ -1,6 +1,6 @@ /* - * $Id: HttpHeader.c,v 1.28.6.1.4.20 2007/12/17 08:17:48 adri Exp $ + * $Id: HttpHeader.c,v 1.28.6.1.4.21 2007/12/20 03:22:36 adri Exp $ * * DEBUG: section 55 HTTP Header * AUTHOR: Alex Rousskov @@ -1114,17 +1114,6 @@ return NULL; } -const char * -httpHeaderGetStr(const HttpHeader * hdr, http_hdr_type id) -{ - String *s; - - s = httpHeaderGetString(hdr, id); - if (s) - return strBuf2(*s); - return NULL; - -} HttpHdrCc * httpHeaderGetCc(const HttpHeader * hdr) Index: squid/src/HttpMsg.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/HttpMsg.c,v retrieving revision 1.12 retrieving revision 1.12.12.1 diff -u -r1.12 -r1.12.12.1 --- squid/src/HttpMsg.c 1 Apr 2007 14:04:42 -0000 1.12 +++ squid/src/HttpMsg.c 20 Dec 2007 03:22:36 -0000 1.12.12.1 @@ -1,6 +1,6 @@ /* - * $Id: HttpMsg.c,v 1.12 2007/04/01 14:04:42 squidadm Exp $ + * $Id: HttpMsg.c,v 1.12.12.1 2007/12/20 03:22:36 adri Exp $ * * DEBUG: section 74 HTTP Message * AUTHOR: Alex Rousskov @@ -116,11 +116,12 @@ * return false if it is a browser connection. If there is a * VIA header, then we assume this is NOT a browser connection. */ - const char *agent = httpHeaderGetStr(hdr, HDR_USER_AGENT); - if (agent && !httpHeaderHas(hdr, HDR_VIA)) { - if (!strncasecmp(agent, "Mozilla/3.", 10)) + /* Weak string referencing */ + String *agent = httpHeaderGetString(hdr, HDR_USER_AGENT); + if (agent && strIsNotNull(*agent) && !httpHeaderHas(hdr, HDR_VIA)) { + if (!strNCaseCmp(*agent, "Mozilla/3.", 10)) return 0; - if (!strncasecmp(agent, "Netscape/3.", 11)) + if (!strNCaseCmp(*agent, "Netscape/3.", 11)) return 0; } /* for old versions of HTTP: persistent if has "keep-alive" */ Index: squid/src/HttpRequest.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/HttpRequest.c,v retrieving revision 1.17.10.1.4.4 retrieving revision 1.17.10.1.4.5 diff -u -r1.17.10.1.4.4 -r1.17.10.1.4.5 --- squid/src/HttpRequest.c 15 Dec 2007 11:09:20 -0000 1.17.10.1.4.4 +++ squid/src/HttpRequest.c 20 Dec 2007 03:22:36 -0000 1.17.10.1.4.5 @@ -1,6 +1,6 @@ /* - * $Id: HttpRequest.c,v 1.17.10.1.4.4 2007/12/15 11:09:20 adri Exp $ + * $Id: HttpRequest.c,v 1.17.10.1.4.5 2007/12/20 03:22:36 adri Exp $ * * DEBUG: section 73 HTTP Request * AUTHOR: Duane Wessels @@ -186,7 +186,7 @@ { assert(e); /* check connection header */ - if (strConn && strListIsMemberStr(strConn, strBuf2(e->name), strLen2(e->name), ',')) + if (strConn && strListIsMemberStr(strConn, &e->name, ',')) return 0; return 1; } Index: squid/src/client_side.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/client_side.c,v retrieving revision 1.202.2.9.4.17 retrieving revision 1.202.2.9.4.18 diff -u -r1.202.2.9.4.17 -r1.202.2.9.4.18 --- squid/src/client_side.c 19 Dec 2007 04:00:52 -0000 1.202.2.9.4.17 +++ squid/src/client_side.c 20 Dec 2007 03:22:36 -0000 1.202.2.9.4.18 @@ -1,6 +1,6 @@ /* - * $Id: client_side.c,v 1.202.2.9.4.17 2007/12/19 04:00:52 adri Exp $ + * $Id: client_side.c,v 1.202.2.9.4.18 2007/12/20 03:22:36 adri Exp $ * * DEBUG: section 33 Client-side Routines * AUTHOR: Duane Wessels @@ -626,8 +626,8 @@ /* Remember the ETag and restart */ if (rep) { request_t *request = http->request; - const char *etag = httpHeaderGetStr(&rep->header, HDR_ETAG); /* XXX This is all very weak vary referencing; its not stringDup() referencing! */ + String *etag = httpHeaderGetString(&rep->header, HDR_ETAG); String vary = request->vary_headers; int has_vary = httpHeaderHas(&rep->header, HDR_VARY); #if X_ACCELERATOR_VARY @@ -638,8 +638,8 @@ vary = request->vary_headers; } - if (etag && strIsNotNull(vary)) { - storeAddVary(url, entry->mem_obj->method, NULL, httpHeaderGetString(&rep->header, HDR_ETAG), &request->vary_hdr, &request->vary_headers, &request->vary_encoding); + if (strIsNotNull(*etag) && strIsNotNull(vary)) { + storeAddVary(url, entry->mem_obj->method, NULL, etag, &request->vary_hdr, &request->vary_headers, &request->vary_encoding); } } clientHandleETagMiss(http); @@ -701,7 +701,7 @@ char *url = http->uri; StoreEntry *entry = NULL; int hit = 0; - const char *etag; + String *etag; const int can_revalidate = http->entry->mem_obj->reply->sline.status == HTTP_OK; debug(33, 3) ("clientProcessExpired: '%s'\n", http->uri); /* @@ -767,9 +767,9 @@ http->entry = entry; http->out.offset = 0; if (can_revalidate) { - etag = httpHeaderGetStr(&http->old_entry->mem_obj->reply->header, HDR_ETAG); - if (etag) { - http->request->etag = xstrdup(etag); + etag = httpHeaderGetString(&http->old_entry->mem_obj->reply->header, HDR_ETAG); + if (strIsNotNull(*etag)) { + http->request->etag = strCDup(*etag); http->request->flags.cache_validation = 1; } } @@ -822,9 +822,10 @@ */ if (httpHeaderHas(&new_entry->mem_obj->reply->header, HDR_ETAG) && httpHeaderHas(&request->header, HDR_IF_NONE_MATCH)) { - const char *etag = httpHeaderGetStr(&new_entry->mem_obj->reply->header, HDR_ETAG); + /* Weak string referencing! */ + String *etag = httpHeaderGetString(&new_entry->mem_obj->reply->header, HDR_ETAG); String etags = httpHeaderGetList(&request->header, HDR_IF_NONE_MATCH); - int etag_match = strListIsMember(&etags, etag, ','); + int etag_match = strListIsMemberStr(&etags, etag, ','); stringClean(&etags); if (etag_match) { debug(33, 5) ("clientGetsOldEntry: NO, client If-None-Match\n"); @@ -1308,7 +1309,6 @@ request_t *request = http->request; HttpHeader *req_hdr = &request->header; int no_cache = 0; - const char *str; request->imslen = -1; request->ims = httpHeaderGetTime(req_hdr, HDR_IF_MODIFIED_SINCE); if (request->ims > 0) @@ -1332,14 +1332,17 @@ */ if (Config.onoff.ie_refresh) { if (http->flags.accel && request->flags.ims) { - if ((str = httpHeaderGetStr(req_hdr, HDR_USER_AGENT))) { - if (strstr(str, "MSIE 5.01") != NULL) + String *ustr; + /* Weak string referencing! */ + ustr = httpHeaderGetString(req_hdr, HDR_USER_AGENT); + if (ustr && strIsNotNull(*ustr)) { + if (strStr(*ustr, "MSIE 5.01") != -1) no_cache++; - else if (strstr(str, "MSIE 5.0") != NULL) + else if (strStr(*ustr, "MSIE 5.0") != -1) no_cache++; - else if (strstr(str, "MSIE 4.") != NULL) + else if (strStr(*ustr, "MSIE 4.") != -1) no_cache++; - else if (strstr(str, "MSIE 3.") != NULL) + else if (strStr(*ustr, "MSIE 3.") != -1) no_cache++; } } @@ -1435,12 +1438,17 @@ stringClean(&s); } #if USE_USERAGENT_LOG - if ((str = httpHeaderGetStr(req_hdr, HDR_USER_AGENT))) - logUserAgent(fqdnFromAddr(http->conn->log_addr), str); + String *s2; + s2 = httpHeaderGetString(req_hdr, HDR_USER_AGENT); + if (s2 && strIsNotNull(*s2)) + logUserAgent(fqdnFromAddr(http->conn->log_addr), *str); #endif #if USE_REFERER_LOG - if ((str = httpHeaderGetStr(req_hdr, HDR_REFERER))) - logReferer(fqdnFromAddr(http->conn->log_addr), str, rfc1738_escape_unescaped(http->uri)); + String *s3; + + s3 = httpHeaderGetString(req_hdr, HDR_USER_AGENT); + if (s3 && strIsNotNull(*s3)) + logReferer(fqdnFromAddr(http->conn->log_addr), *str, rfc1738_escape_unescaped(http->uri)); #endif #if FORW_VIA_DB if (httpHeaderHas(req_hdr, HDR_X_FORWARDED_FOR)) { @@ -1604,17 +1612,18 @@ return 0; /* got an ETag? */ if (spec.tag) { - const char *rep_tag = httpHeaderGetStr(&rep->header, HDR_ETAG); - debug(33, 3) ("clientIfRangeMatch: ETags: %s and %s\n", - spec.tag, rep_tag ? rep_tag : ""); - if (!rep_tag) + /* Weak string reference */ + String *rep_tag = httpHeaderGetString(&rep->header, HDR_ETAG); + debug(33, 3) ("clientIfRangeMatch: ETags: %s and %.*s\n", + spec.tag, rep_tag ? strLen2(*rep_tag) : 6, rep_tag ? strBuf2(*rep_tag) : ""); + if (!rep_tag || strIsNull(*rep_tag)) return 0; /* entity has no etag to compare with! */ - if (spec.tag[0] == 'W' || rep_tag[0] == 'W') { - debug(33, 1) ("clientIfRangeMatch: Weak ETags are not allowed in If-Range: %s ? %s\n", - spec.tag, rep_tag); + if (spec.tag[0] == 'W' || strGetPos(*rep_tag, 0) == 'W') { + debug(33, 1) ("clientIfRangeMatch: Weak ETags are not allowed in If-Range: %s ? %.*s\n", + spec.tag, strLen2(*rep_tag), strBuf2(*rep_tag)); return 0; /* must use strong validator for sub-range requests */ } - return strcmp(rep_tag, spec.tag) == 0; + return strCmp(*rep_tag, spec.tag) == 0; } /* got modification time? */ else if (spec.time >= 0) { @@ -1771,7 +1780,7 @@ while ((e = httpHeaderGetEntry(hdr, &pos))) { if (e->id == HDR_KEEP_ALIVE) continue; /* Common, and already taken care of above */ - if (strListIsMemberStr(&strConnection, strBuf2(e->name), strLen2(e->name), ',')) { + if (strListIsMemberStr(&strConnection, &e->name, ',')) { httpHeaderDelAt(hdr, pos); headers_deleted++; } @@ -2145,9 +2154,10 @@ else request->lastmod = -1; if (!request->etag) { - const char *etag = httpHeaderGetStr(&async->old_entry->mem_obj->reply->header, HDR_ETAG); - if (etag) - async->request->etag = xstrdup(etag); + /* Weak string reference */ + String *etag = httpHeaderGetString(&async->old_entry->mem_obj->reply->header, HDR_ETAG); + if (etag && strIsNotNull(*etag)) + async->request->etag = strCDup(*etag); } #if DELAY_POOLS /* delay_id is already set on original store client */ @@ -2278,11 +2288,12 @@ return; } if (httpHeaderHas(&r->header, HDR_IF_MATCH)) { - const char *rep_etag = httpHeaderGetStr(&e->mem_obj->reply->header, HDR_ETAG); + /* Weak string reference */ + String *rep_etag = httpHeaderGetString(&e->mem_obj->reply->header, HDR_ETAG); int has_etag = 0; - if (rep_etag) { + if (rep_etag && strIsNotNull(*rep_etag)) { String req_etags = httpHeaderGetList(&http->request->header, HDR_IF_MATCH); - has_etag = strListIsMember(&req_etags, rep_etag, ','); + has_etag = strListIsMemberStr(&req_etags, rep_etag, ','); stringClean(&req_etags); } if (!has_etag) { @@ -2296,7 +2307,7 @@ } if (httpHeaderHas(&r->header, HDR_IF_NONE_MATCH)) { String req_etags; - const char *rep_etag = httpHeaderGetStr(&e->mem_obj->reply->header, HDR_ETAG); + String *rep_etag = httpHeaderGetString(&e->mem_obj->reply->header, HDR_ETAG); int has_etag; if (mem->reply->sline.status != HTTP_OK) { debug(33, 4) ("clientCacheHit: Reply code %d != 200\n", @@ -2305,9 +2316,9 @@ clientProcessMiss(http); return; } - if (rep_etag) { + if (rep_etag && strIsNotNull(*rep_etag)) { req_etags = httpHeaderGetList(&http->request->header, HDR_IF_NONE_MATCH); - has_etag = strListIsMember(&req_etags, rep_etag, ','); + has_etag = strListIsMemberStr(&req_etags, rep_etag, ','); stringClean(&req_etags); if (has_etag) { debug(33, 4) ("clientCacheHit: If-None-Match matches\n"); @@ -2445,8 +2456,11 @@ /* stuff the header with required entries and pack it */ httpHeaderInit(&hdr, hoReply); - if (httpHeaderHas(&rep->header, HDR_CONTENT_TYPE)) - httpHeaderPutStr(&hdr, HDR_CONTENT_TYPE, httpHeaderGetStr(&rep->header, HDR_CONTENT_TYPE)); + if (httpHeaderHas(&rep->header, HDR_CONTENT_TYPE)) { + String *s = httpHeaderGetString(&rep->header, HDR_CONTENT_TYPE); + /* Weak reference; PutString will eventually dup correctly what we pass it */ + httpHeaderPutString(&hdr, HDR_CONTENT_TYPE, *s); + } httpHeaderAddContRange(&hdr, *spec, rep->content_length); packerToMemInit(&p, mb); httpHeaderPackInto(&hdr, &p); @@ -2790,10 +2804,12 @@ /* We have to restore the URL as sent by the client */ request_t *req = http->orig_request; const char *proto = conn->port->protocol; - const char *host = httpHeaderGetStr(&req->header, HDR_HOST); - if (!host) - host = req->host; - httpHeaderPutStrf(&rep->header, HDR_LOCATION, "%s://%s%s", proto, host, reply); + /* Weak reference */ + String *h2 = httpHeaderGetString(&req->header, HDR_HOST); + if (h2 && strIsNotNull(*h2)) + httpHeaderPutStrf(&rep->header, HDR_LOCATION, "%s://%.*s%s", proto, strLen2(*h2), strBuf2(*h2), reply); + else + httpHeaderPutStrf(&rep->header, HDR_LOCATION, "%s://%s%s", proto, req->host, reply); } else { httpHeaderPutStr(&rep->header, HDR_LOCATION, reply); } Index: squid/src/errormap.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/errormap.c,v retrieving revision 1.4.12.1.4.1 retrieving revision 1.4.12.1.4.2 diff -u -r1.4.12.1.4.1 -r1.4.12.1.4.2 --- squid/src/errormap.c 14 Dec 2007 13:07:15 -0000 1.4.12.1.4.1 +++ squid/src/errormap.c 20 Dec 2007 03:22:37 -0000 1.4.12.1.4.2 @@ -158,7 +158,7 @@ int len = 0; const char *errorUrl; ErrorMapState *state; - const char *tmp; + String *tmp; http_status status; request_t *req; HttpHeaderPos hdrpos; @@ -169,10 +169,11 @@ status = reply->sline.status; - tmp = httpHeaderGetStr(&reply->header, HDR_X_SQUID_ERROR); + /* Weak string referencing */ + tmp = httpHeaderGetString(&reply->header, HDR_X_SQUID_ERROR); squid_error[0] = '\0'; - if (tmp) { - xstrncpy(squid_error, tmp, sizeof(squid_error)); + if (tmp && strIsNotNull(*tmp)) { + strncat(squid_error, strBuf2(*tmp), XMIN(strLen2(*tmp), sizeof(squid_error - 2))); len = strcspn(squid_error, " "); } squid_error[len] = '\0'; Index: squid/src/http.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/http.c,v retrieving revision 1.63.2.3.4.14 retrieving revision 1.63.2.3.4.15 diff -u -r1.63.2.3.4.14 -r1.63.2.3.4.15 --- squid/src/http.c 19 Dec 2007 04:00:56 -0000 1.63.2.3.4.14 +++ squid/src/http.c 20 Dec 2007 03:22:37 -0000 1.63.2.3.4.15 @@ -1,6 +1,6 @@ /* - * $Id: http.c,v 1.63.2.3.4.14 2007/12/19 04:00:56 adri Exp $ + * $Id: http.c,v 1.63.2.3.4.15 2007/12/20 03:22:37 adri Exp $ * * DEBUG: section 11 Hypertext Transfer Protocol (HTTP) * AUTHOR: Harvest Derived @@ -226,7 +226,7 @@ HttpReply *rep = httpState->entry->mem_obj->reply; HttpHeader *hdr = &rep->header; const int cc_mask = (rep->cache_control) ? rep->cache_control->mask : 0; - const char *v; + String *v; #if HTTP_VIOLATIONS const refresh_t *R = NULL; /* This strange looking define first looks up the frefresh pattern @@ -268,8 +268,9 @@ * continuous push replies. These are generally dynamic and * probably should not be cachable */ - if ((v = httpHeaderGetStr(hdr, HDR_CONTENT_TYPE))) - if (!strncasecmp(v, "multipart/x-mixed-replace", 25)) + /* Weak string reference */ + v = httpHeaderGetString(hdr, HDR_CONTENT_TYPE); + if (v && strIsNotNull(*v) && (! strNCaseCmp(*v, "multipart/x-mixed-replace", 25))) return 0; switch (httpState->entry->mem_obj->reply->sline.status) { /* Responses that are cacheable */ @@ -618,7 +619,7 @@ header = httpHeaderGetStrOrList(hdr, HDR_PROXY_SUPPORT); /* XXX This ought to be done in a case-insensitive manner */ - rc = (strStr(header, "Session-Based-Authentication") != NULL); + rc = (strStr(header, "Session-Based-Authentication") != -1); stringClean(&header); return rc; @@ -1297,9 +1298,10 @@ /* Special mode, convert proxy authentication to WWW authentication * (also applies to cookie authentication) */ - const char *auth = httpHeaderGetStr(hdr_in, HDR_PROXY_AUTHORIZATION); - if (auth && strncasecmp(auth, "basic ", 6) == 0) { - httpHeaderPutStr(hdr_out, HDR_AUTHORIZATION, auth); + /* Weak string referencing */ + String *auth = httpHeaderGetString(hdr_in, HDR_PROXY_AUTHORIZATION); + if (auth && strIsNotNull(*auth) && strNCaseCmp(*auth, "basic ", 6) == 0) { + httpHeaderPutString(hdr_out, HDR_AUTHORIZATION, *auth); if (orig_request->flags.connection_auth) orig_request->flags.pinned = 1; } else if (orig_request->extacl_user && orig_request->extacl_passwd) { Index: squid/src/locrewrite.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/locrewrite.c,v retrieving revision 1.4 retrieving revision 1.4.54.1 diff -u -r1.4 -r1.4.54.1 --- squid/src/locrewrite.c 16 May 2006 04:50:45 -0000 1.4 +++ squid/src/locrewrite.c 20 Dec 2007 03:22:37 -0000 1.4.54.1 @@ -1,6 +1,6 @@ /* - * $Id: locrewrite.c,v 1.4 2006/05/16 04:50:45 squidadm Exp $ + * $Id: locrewrite.c,v 1.4.54.1 2007/12/20 03:22:37 adri Exp $ * * DEBUG: section 29 Redirector * AUTHOR: Henrik Nordstrom @@ -92,7 +92,8 @@ locationRewriteStart(HttpReply * rep, clientHttpRequest * http, RH * handler, void *data) { rewriteStateData *r = NULL; - const char *location = httpHeaderGetStr(&rep->header, HDR_LOCATION); + /* Weak string referencing */ + String *location = httpHeaderGetString(&rep->header, HDR_LOCATION); const char *urlgroup; char buf[8192]; @@ -106,7 +107,7 @@ assert(handler); if (!urlgroup || !*urlgroup) urlgroup = "-"; - debug(29, 5) ("locationRewriteStart: '%s'\n", location); + debug(29, 5) ("locationRewriteStart: '%.*s'\n", strLen2(*location), strBuf2(*location)); if (Config.Program.location_rewrite.command == NULL) { handler(data, NULL); return; @@ -118,7 +119,7 @@ return; } r = cbdataAlloc(rewriteStateData); - r->orig_url = xstrdup(location); + r->orig_url = strCDup(*location); r->handler = handler; r->data = data; cbdataLock(r->data); Index: squid/src/protos.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/protos.h,v retrieving revision 1.146.2.4.4.27 retrieving revision 1.146.2.4.4.28 diff -u -r1.146.2.4.4.27 -r1.146.2.4.4.28 --- squid/src/protos.h 19 Dec 2007 05:51:49 -0000 1.146.2.4.4.27 +++ squid/src/protos.h 20 Dec 2007 03:22:37 -0000 1.146.2.4.4.28 @@ -1,6 +1,6 @@ /* - * $Id: protos.h,v 1.146.2.4.4.27 2007/12/19 05:51:49 adri Exp $ + * $Id: protos.h,v 1.146.2.4.4.28 2007/12/20 03:22:37 adri Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -441,9 +441,7 @@ extern HttpHdrCc *httpHeaderGetCc(const HttpHeader * hdr); extern HttpHdrRange *httpHeaderGetRange(const HttpHeader * hdr); extern HttpHdrContRange *httpHeaderGetContRange(const HttpHeader * hdr); -extern const char *httpHeaderGetStr(const HttpHeader * hdr, http_hdr_type id); extern String * httpHeaderGetString(const HttpHeader * hdr, http_hdr_type id); -extern const char *httpHeaderGetLastStr(const HttpHeader * hdr, http_hdr_type id); extern const char *httpHeaderGetAuth(const HttpHeader * hdr, http_hdr_type id, const char *auth_scheme); extern String httpHeaderGetList(const HttpHeader * hdr, http_hdr_type id); extern String httpHeaderGetStrOrList(const HttpHeader * hdr, http_hdr_type id); @@ -1140,11 +1138,11 @@ extern void useragentOpenLog(void); extern void useragentRotateLog(void); -extern void logUserAgent(const char *, const char *); +extern void logUserAgent(const char *, String); extern void useragentLogClose(void); extern void refererOpenLog(void); extern void refererRotateLog(void); -extern void logReferer(const char *, const char *, const char *); +extern void logReferer(const char *, String, const char *); extern void refererCloseLog(void); extern peer_t parseNeighborType(const char *s); Index: squid/src/referer.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/referer.c,v retrieving revision 1.7 retrieving revision 1.7.8.1 diff -u -r1.7 -r1.7.8.1 --- squid/src/referer.c 23 Sep 2007 14:51:45 -0000 1.7 +++ squid/src/referer.c 20 Dec 2007 03:22:38 -0000 1.7.8.1 @@ -64,16 +64,16 @@ } void -logReferer(const char *client, const char *referer, const char *uri) +logReferer(const char *client, String referer, const char *uri) { #if USE_REFERER_LOG if (NULL == refererlog) return; - logfilePrintf(refererlog, "%9d.%03d %s %s %s\n", + logfilePrintf(refererlog, "%9d.%03d %s %.*s %s\n", (int) current_time.tv_sec, (int) current_time.tv_usec / 1000, client, - referer, + strLen2(referer), strBuf2(referer), uri ? uri : "-"); #endif } Index: squid/src/structs.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/structs.h,v retrieving revision 1.158.2.5.4.5 retrieving revision 1.158.2.5.4.6 diff -u -r1.158.2.5.4.5 -r1.158.2.5.4.6 --- squid/src/structs.h 14 Dec 2007 07:09:38 -0000 1.158.2.5.4.5 +++ squid/src/structs.h 20 Dec 2007 03:22:38 -0000 1.158.2.5.4.6 @@ -1,6 +1,6 @@ /* - * $Id: structs.h,v 1.158.2.5.4.5 2007/12/14 07:09:38 adri Exp $ + * $Id: structs.h,v 1.158.2.5.4.6 2007/12/20 03:22:38 adri Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -1097,6 +1097,7 @@ }; struct _HttpStateData { + buf_t *replybuf; StoreEntry *entry; request_t *request; MemBuf reply_hdr; Index: squid/src/useragent.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/useragent.c,v retrieving revision 1.9 retrieving revision 1.9.8.1 diff -u -r1.9 -r1.9.8.1 --- squid/src/useragent.c 23 Sep 2007 14:51:45 -0000 1.9 +++ squid/src/useragent.c 20 Dec 2007 03:22:38 -0000 1.9.8.1 @@ -1,6 +1,6 @@ /* - * $Id: useragent.c,v 1.9 2007/09/23 14:51:45 squidadm Exp $ + * $Id: useragent.c,v 1.9.8.1 2007/12/20 03:22:38 adri Exp $ * * DEBUG: section 40 User-Agent logging * AUTHOR: Joe Ramey @@ -63,7 +63,7 @@ } void -logUserAgent(const char *client, const char *agent) +logUserAgent(const char *client, String agent) { #if USE_USERAGENT_LOG static time_t last_time = 0; @@ -76,10 +76,10 @@ strcpy(time_str, s); last_time = squid_curtime; } - logfilePrintf(useragentlog, "%s [%s] \"%s\"\n", + logfilePrintf(useragentlog, "%s [%s] \"%.*s\"\n", client, time_str, - agent); + strLen2(agent), strBuf2(agent)); #endif }