--------------------- PatchSet 10249 Date: 2007/12/15 11:09:20 Author: adri Branch: s27_adri Tag: (none) Log: * More packing tape to propagate string lengths to library functions. * Make sure const char's aren't modified in urlParse() (since we're passing it const char *'s) * remove a couple more strBuf() calls Members: src/HttpRequest.c:1.17.10.1.4.3->1.17.10.1.4.4 src/client_side.c:1.202.2.9.4.14->1.202.2.9.4.15 src/http.c:1.63.2.3.4.9->1.63.2.3.4.10 src/internal.c:1.15.12.2->1.15.12.3 src/mime.c:1.19.12.1->1.19.12.2 src/protos.h:1.146.2.4.4.17->1.146.2.4.4.18 src/store_digest.c:1.14.12.1->1.14.12.2 src/store_swapmeta.c:1.12.22.1.4.1->1.12.22.1.4.2 src/url.c:1.22.12.2->1.22.12.3 Index: squid/src/HttpRequest.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/HttpRequest.c,v retrieving revision 1.17.10.1.4.3 retrieving revision 1.17.10.1.4.4 diff -u -r1.17.10.1.4.3 -r1.17.10.1.4.4 --- squid/src/HttpRequest.c 14 Dec 2007 06:11:26 -0000 1.17.10.1.4.3 +++ squid/src/HttpRequest.c 15 Dec 2007 11:09:20 -0000 1.17.10.1.4.4 @@ -1,6 +1,6 @@ /* - * $Id: HttpRequest.c,v 1.17.10.1.4.3 2007/12/14 06:11:26 adri Exp $ + * $Id: HttpRequest.c,v 1.17.10.1.4.4 2007/12/15 11:09:20 adri Exp $ * * DEBUG: section 73 HTTP Request * AUTHOR: Duane Wessels @@ -36,13 +36,16 @@ #include "squid.h" request_t * -requestCreate(method_t method, protocol_t protocol, const char *urlpath) +requestCreate(method_t method, protocol_t protocol, const char *urlpath, int len) { request_t *req = memAllocate(MEM_REQUEST_T); req->method = method; req->protocol = protocol; - if (urlpath) - stringReset(&req->urlpath, urlpath); + if (urlpath) { + /* XXX is this really needed? */ + stringClean(&req->urlpath); + stringLimitInit(&req->urlpath, urlpath, len); + } req->max_forwards = -1; req->lastmod = -1; req->client_addr = no_addr; Index: squid/src/client_side.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/client_side.c,v retrieving revision 1.202.2.9.4.14 retrieving revision 1.202.2.9.4.15 diff -u -r1.202.2.9.4.14 -r1.202.2.9.4.15 --- squid/src/client_side.c 14 Dec 2007 13:07:12 -0000 1.202.2.9.4.14 +++ squid/src/client_side.c 15 Dec 2007 11:09:20 -0000 1.202.2.9.4.15 @@ -1,6 +1,6 @@ /* - * $Id: client_side.c,v 1.202.2.9.4.14 2007/12/14 13:07:12 adri Exp $ + * $Id: client_side.c,v 1.202.2.9.4.15 2007/12/15 11:09:20 adri Exp $ * * DEBUG: section 33 Client-side Routines * AUTHOR: Duane Wessels @@ -419,7 +419,7 @@ * so make a fake one. */ if (h->request == NULL) - h->request = requestLink(requestCreate(m, PROTO_NONE, null_string)); + h->request = requestLink(requestCreate(m, PROTO_NONE, null_string, 0)); e = storeCreateEntry(h->uri, flags, m); if (h->request->store_url) storeEntrySetStoreUrl(e, h->request->store_url); @@ -3622,7 +3622,7 @@ } else if (*url == '/' && Config.onoff.global_internal_static && internalCheck(url)) { internal: /* prepend our name & port */ - http->uri = xstrdup(internalStoreUri("", url)); + http->uri = xstrdup(internalStoreUri("", url, strlen(url))); http->flags.internal = 1; http->flags.accel = 1; debug(33, 5) ("INTERNAL REWRITE: '%s'\n", http->uri); @@ -3874,7 +3874,7 @@ request_t *old_request = requestLink(request); const char *url; - url = internalStoreUri("", strBuf(request->urlpath)); + url = internalStoreUri("", strBuf2(request->urlpath), strLen2(request->urlpath)); request = urlParse(method, url, strlen(url)); httpHeaderAppend(&request->header, &old_request->header); requestUnlink(old_request); Index: squid/src/http.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/http.c,v retrieving revision 1.63.2.3.4.9 retrieving revision 1.63.2.3.4.10 diff -u -r1.63.2.3.4.9 -r1.63.2.3.4.10 --- squid/src/http.c 15 Dec 2007 10:43:27 -0000 1.63.2.3.4.9 +++ squid/src/http.c 15 Dec 2007 11:09:22 -0000 1.63.2.3.4.10 @@ -1,6 +1,6 @@ /* - * $Id: http.c,v 1.63.2.3.4.9 2007/12/15 10:43:27 adri Exp $ + * $Id: http.c,v 1.63.2.3.4.10 2007/12/15 11:09:22 adri Exp $ * * DEBUG: section 11 Hypertext Transfer Protocol (HTTP) * AUTHOR: Harvest Derived @@ -1473,7 +1473,7 @@ else url = storeUrl(httpState->entry); proxy_req = requestCreate(orig_req->method, - orig_req->protocol, url); + orig_req->protocol, url, strlen(url)); xstrncpy(proxy_req->host, httpState->peer->host, SQUIDHOSTNAMELEN); proxy_req->port = httpState->peer->http_port; proxy_req->flags = orig_req->flags; Index: squid/src/internal.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/internal.c,v retrieving revision 1.15.12.2 retrieving revision 1.15.12.3 diff -u -r1.15.12.2 -r1.15.12.3 --- squid/src/internal.c 12 Dec 2007 11:48:58 -0000 1.15.12.2 +++ squid/src/internal.c 15 Dec 2007 11:09:24 -0000 1.15.12.3 @@ -1,6 +1,6 @@ /* - * $Id: internal.c,v 1.15.12.2 2007/12/12 11:48:58 adri Exp $ + * $Id: internal.c,v 1.15.12.3 2007/12/15 11:09:24 adri Exp $ * * DEBUG: section 76 Internal Squid Object handling * AUTHOR: Duane, Alex, Henrik @@ -135,11 +135,11 @@ * makes internal url for store */ char * -internalStoreUri(const char *dir, const char *name) +internalStoreUri(const char *dir, const char *name, int len) { static MemBuf mb = MemBufNULL; memBufReset(&mb); - memBufPrintf(&mb, "internal://%s%s%s", internalUniqueHostname(), dir ? dir : "", name); + memBufPrintf(&mb, "internal://%s%s%.*s", internalUniqueHostname(), dir ? dir : "", len, name); return mb.buf; } Index: squid/src/mime.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/mime.c,v retrieving revision 1.19.12.1 retrieving revision 1.19.12.2 diff -u -r1.19.12.1 -r1.19.12.2 --- squid/src/mime.c 14 Dec 2007 13:07:15 -0000 1.19.12.1 +++ squid/src/mime.c 15 Dec 2007 11:09:24 -0000 1.19.12.2 @@ -1,6 +1,6 @@ /* - * $Id: mime.c,v 1.19.12.1 2007/12/14 13:07:15 adri Exp $ + * $Id: mime.c,v 1.19.12.2 2007/12/15 11:09:24 adri Exp $ * * DEBUG: section 25 MIME Parsing * AUTHOR: Harvest Derived @@ -409,7 +409,7 @@ request_t *r; if (type == NULL) fatal("Unknown icon format while reading mime.conf\n"); - buf = internalStoreUri("/squid-internal-static/icons/", icon); + buf = internalStoreUri("/squid-internal-static/icons/", icon, strlen(icon)); xstrncpy(url, buf, MAX_URL); if (storeGetPublic(url, METHOD_GET)) return; Index: squid/src/protos.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/protos.h,v retrieving revision 1.146.2.4.4.17 retrieving revision 1.146.2.4.4.18 diff -u -r1.146.2.4.4.17 -r1.146.2.4.4.18 --- squid/src/protos.h 14 Dec 2007 13:07:16 -0000 1.146.2.4.4.17 +++ squid/src/protos.h 15 Dec 2007 11:09:24 -0000 1.146.2.4.4.18 @@ -1,6 +1,6 @@ /* - * $Id: protos.h,v 1.146.2.4.4.17 2007/12/14 13:07:16 adri Exp $ + * $Id: protos.h,v 1.146.2.4.4.18 2007/12/15 11:09:24 adri Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -508,7 +508,7 @@ extern HttpReply *httpReplyClone(HttpReply * src); /* Http Request */ -extern request_t *requestCreate(method_t, protocol_t, const char *urlpath); +extern request_t *requestCreate(method_t, protocol_t, const char *urlpath, int len); extern void requestDestroy(request_t *); extern request_t *requestLink(request_t *); extern void requestUnlink(request_t *); @@ -1131,7 +1131,7 @@ extern protocol_t urlParseProtocol(const char *); extern method_t urlParseMethod(const char *, int len); extern void urlInitialize(void); -extern request_t *urlParse(method_t, char *, int); +extern request_t *urlParse(method_t, const char *, int); extern const char *urlCanonical(request_t *); extern char *urlRInternal(const char *host, u_short port, const char *dir, const char *name); extern char *urlInternal(const char *dir, const char *name); @@ -1231,7 +1231,7 @@ extern int internalCheck(const char *urlpath); extern int internalStaticCheck(String urlpath); extern char *internalLocalUri(const char *dir, const char *name); -extern char *internalStoreUri(const char *dir, const char *name); +extern char *internalStoreUri(const char *dir, const char *name, int len); extern char *internalRemoteUri(const char *, u_short, const char *, const char *); extern const char *internalHostname(void); extern int internalHostnameIs(const char *); Index: squid/src/store_digest.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/store_digest.c,v retrieving revision 1.14.12.1 retrieving revision 1.14.12.2 diff -u -r1.14.12.1 -r1.14.12.2 --- squid/src/store_digest.c 14 Dec 2007 13:07:17 -0000 1.14.12.1 +++ squid/src/store_digest.c 15 Dec 2007 11:09:24 -0000 1.14.12.2 @@ -1,6 +1,6 @@ /* - * $Id: store_digest.c,v 1.14.12.1 2007/12/14 13:07:17 adri Exp $ + * $Id: store_digest.c,v 1.14.12.2 2007/12/15 11:09:24 adri Exp $ * * DEBUG: section 71 Store Digest Manager * AUTHOR: Alex Rousskov @@ -347,7 +347,7 @@ } debug(71, 2) ("storeDigestRewrite: start rewrite #%d\n", sd_state.rewrite_count + 1); /* make new store entry */ - url = internalStoreUri("/squid-internal-periodic/", StoreDigestFileName); + url = internalStoreUri("/squid-internal-periodic/", StoreDigestFileName, strlen(StoreDigestFileName)); flags = null_request_flags; flags.cachable = 1; e = storeCreateEntry(url, flags, METHOD_GET); Index: squid/src/store_swapmeta.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/store_swapmeta.c,v retrieving revision 1.12.22.1.4.1 retrieving revision 1.12.22.1.4.2 diff -u -r1.12.22.1.4.1 -r1.12.22.1.4.2 --- squid/src/store_swapmeta.c 14 Dec 2007 06:11:30 -0000 1.12.22.1.4.1 +++ squid/src/store_swapmeta.c 15 Dec 2007 11:09:24 -0000 1.12.22.1.4.2 @@ -1,6 +1,6 @@ /* - * $Id: store_swapmeta.c,v 1.12.22.1.4.1 2007/12/14 06:11:30 adri Exp $ + * $Id: store_swapmeta.c,v 1.12.22.1.4.2 2007/12/15 11:09:24 adri Exp $ * * DEBUG: section 20 Storage Manager Swapfile Metadata * AUTHOR: Kostas Anagnostakis @@ -67,7 +67,6 @@ tlv *TLV = NULL; /* we'll return this */ tlv **T = &TLV; const char *url; - const char *vary; const squid_off_t objsize = objectLen(e); assert(e->mem_obj != NULL); assert(e->swap_status == SWAPOUT_WRITING); Index: squid/src/url.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/url.c,v retrieving revision 1.22.12.2 retrieving revision 1.22.12.3 diff -u -r1.22.12.2 -r1.22.12.3 --- squid/src/url.c 14 Dec 2007 13:07:17 -0000 1.22.12.2 +++ squid/src/url.c 15 Dec 2007 11:09:25 -0000 1.22.12.3 @@ -1,6 +1,6 @@ /* - * $Id: url.c,v 1.22.12.2 2007/12/14 13:07:17 adri Exp $ + * $Id: url.c,v 1.22.12.3 2007/12/15 11:09:25 adri Exp $ * * DEBUG: section 23 URL Parsing * AUTHOR: Duane Wessels @@ -109,7 +109,7 @@ "TOTAL" }; -static request_t *urnParse(method_t method, char *urn); +static request_t *urnParse(method_t method, const char *urn, int len); static const char valid_hostname_chars_u[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "abcdefghijklmnopqrstuvwxyz" @@ -256,7 +256,7 @@ * being "end of host with implied path of /". */ request_t * -urlParse(method_t method, char *url, int l) +urlParse(method_t method, const char *url, int l) { LOCAL_ARRAY(char, proto, MAX_URL); LOCAL_ARRAY(char, login, MAX_URL); @@ -274,7 +274,7 @@ if (l + Config.appendDomainLen > (MAX_URL - 1)) { /* terminate so it doesn't overflow other buffers */ - *(url + (MAX_URL >> 1)) = '\0'; + //*(url + (MAX_URL >> 1)) = '\0'; debug(23, 1) ("urlParse: URL too large (%d bytes)\n", l); return NULL; } @@ -283,7 +283,7 @@ if (sscanf(url, "%[^:]:%d", host, &port) < 1) return NULL; } else if (!strncmp(url, "urn:", 4)) { - return urnParse(method, url); + return urnParse(method, url, l); } else { /* Parse the URL: */ src = url; @@ -410,7 +410,7 @@ *q = '\0'; } } - request = requestCreate(method, protocol, urlpath); + request = requestCreate(method, protocol, urlpath, strlen(urlpath)); xstrncpy(request->host, host, SQUIDHOSTNAMELEN); xstrncpy(request->login, login, MAX_LOGIN_SZ); request->port = (u_short) port; @@ -418,10 +418,10 @@ } static request_t * -urnParse(method_t method, char *urn) +urnParse(method_t method, const char *urn, int len) { - debug(50, 5) ("urnParse: %s\n", urn); - return requestCreate(method, PROTO_URN, urn + 4); + debug(50, 5) ("urnParse: %.*s\n", len, urn); + return requestCreate(method, PROTO_URN, urn + 4, len - 4); } const char *