From: wessels <> Date: Tue, 8 Oct 1996 20:48:34 +0000 (+0000) Subject: upload patch X-Git-Tag: SQUID_3_0_PRE1~5703 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4768dbe0b9a26ffcbc64915efee53ab9119c1265;p=thirdparty%2Fsquid.git upload patch --- diff --git a/src/http.cc b/src/http.cc index 20a22a1915..ec7f8e7e41 100644 --- a/src/http.cc +++ b/src/http.cc @@ -1,5 +1,5 @@ /* - * $Id: http.cc,v 1.79 1996/09/20 06:28:49 wessels Exp $ + * $Id: http.cc,v 1.80 1996/10/08 14:48:34 wessels Exp $ * * DEBUG: section 11 Hypertext Transfer Protocol (HTTP) * AUTHOR: Harvest Derived @@ -557,6 +557,7 @@ httpSendRequest(int fd, HttpStateData * httpState) char *buf = NULL; char *t = NULL; char *post_buf = NULL; + int post_buf_sz = 0; static char *crlf = "\r\n"; int len = 0; int buflen; @@ -569,12 +570,15 @@ httpSendRequest(int fd, HttpStateData * httpState) debug(11, 5, "httpSendRequest: FD %d: httpState %p.\n", fd, httpState); buflen = strlen(Method) + strlen(req->urlpath); if (httpState->req_hdr) - buflen += strlen(httpState->req_hdr); + buflen += httpState->req_hdr_sz + 1; buflen += 512; /* lots of extra */ if ((req->method == METHOD_POST || req->method == METHOD_PUT) && httpState->req_hdr) { if ((t = mime_headers_end(httpState->req_hdr))) { - post_buf = xstrdup(t); + post_buf_sz = httpState->req_hdr_sz - (t - httpState->req_hdr); + post_buf = xmalloc(post_buf_sz + 1); + xmemcpy(post_buf, t, post_buf_sz); + *(post_buf + post_buf_sz) = '\0'; *t = '\0'; } } @@ -631,8 +635,8 @@ httpSendRequest(int fd, HttpStateData * httpState) strcat(buf, crlf); len += 2; if (post_buf) { - strcat(buf, post_buf); - len += strlen(post_buf); + xmemcpy(buf + len, post_buf, post_buf_sz); + len += post_buf_sz; xfree(post_buf); } debug(11, 6, "httpSendRequest: FD %d:\n%s\n", fd, buf); @@ -707,6 +711,7 @@ proxyhttpStart(edge * e, char *url, StoreEntry * entry) httpState = xcalloc(1, sizeof(HttpStateData)); storeLockObject(httpState->entry = entry, NULL, NULL); httpState->req_hdr = entry->mem_obj->mime_hdr; + httpState->req_hdr_sz = entry->mem_obj->mime_hdr_sz; request = get_free_request_t(); httpState->request = requestLink(request); httpState->neighbor = e; @@ -769,7 +774,12 @@ httpConnect(int fd, struct hostent *hp, void *data) } int -httpStart(int unusedfd, char *url, request_t * request, char *req_hdr, StoreEntry * entry) +httpStart(int unusedfd, + char *url, + request_t * request, + char *req_hdr, + int req_hdr_sz, + StoreEntry * entry) { /* Create state structure. */ int sock; @@ -794,6 +804,7 @@ httpStart(int unusedfd, char *url, request_t * request, char *req_hdr, StoreEntr httpState = xcalloc(1, sizeof(HttpStateData)); storeLockObject(httpState->entry = entry, NULL, NULL); httpState->req_hdr = req_hdr; + httpState->req_hdr_sz = req_hdr_sz; httpState->request = requestLink(request); comm_add_close_handler(sock, (PF) httpStateFree, diff --git a/src/store.cc b/src/store.cc index 0f6e78f608..d886cf41e3 100644 --- a/src/store.cc +++ b/src/store.cc @@ -1,6 +1,6 @@ /* - * $Id: store.cc,v 1.124 1996/10/07 14:40:09 wessels Exp $ + * $Id: store.cc,v 1.125 1996/10/08 14:48:37 wessels Exp $ * * DEBUG: section 20 Storeage Manager * AUTHOR: Harvest Derived @@ -724,7 +724,11 @@ storeSetPublicKey(StoreEntry * e) } StoreEntry * -storeCreateEntry(char *url, char *req_hdr, int flags, method_t method) +storeCreateEntry(char *url, + char *req_hdr, + int req_hdr_sz, + int flags, + method_t method) { StoreEntry *e = NULL; MemObject *mem = NULL; @@ -736,8 +740,12 @@ storeCreateEntry(char *url, char *req_hdr, int flags, method_t method) e->url = xstrdup(url); meta_data.url_strings += strlen(url); e->method = method; - if (req_hdr) - mem->mime_hdr = xstrdup(req_hdr); + if (req_hdr) { + mem->mime_hdr_sz = req_hdr_sz; + mem->mime_hdr = xmalloc(req_hdr_sz + 1); + xmemcpy(mem->mime_hdr, req_hdr, req_hdr_sz); + *(mem->mime_hdr + req_hdr_sz) = '\0'; + } if (BIT_TEST(flags, REQ_CACHABLE)) { BIT_SET(e->flag, ENTRY_CACHABLE); BIT_RESET(e->flag, RELEASE_REQUEST);