From: wessels <> Date: Thu, 1 Jan 1998 06:55:12 +0000 (+0000) Subject: From: Henrik Nordstrom X-Git-Tag: SQUID_3_0_PRE1~4310 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6fa92aa2dc72fa0f98557df57108cbf5f3977d8c;p=thirdparty%2Fsquid.git From: Henrik Nordstrom strdup on the request buffer is not a great idea * The buffer can contain NULL bytes. * Unneded overhead memmove does the job much better, and without corrupting the data on the way. --- diff --git a/src/client_side.cc b/src/client_side.cc index 860f418381..9d58e2e2d8 100644 --- a/src/client_side.cc +++ b/src/client_side.cc @@ -1,6 +1,6 @@ /* - * $Id: client_side.cc,v 1.180 1997/12/31 22:11:56 wessels Exp $ + * $Id: client_side.cc,v 1.181 1997/12/31 23:55:12 wessels Exp $ * * DEBUG: section 33 Client-side Routines * AUTHOR: Duane Wessels @@ -1591,11 +1591,12 @@ clientReadRequest(int fd, void *data) assert(http->req_sz > 0); conn->in.offset -= http->req_sz; assert(conn->in.offset >= 0); - if (conn->in.offset > 0) { - tmp = xstrdup(conn->in.buf + http->req_sz); - xstrncpy(conn->in.buf, tmp, conn->in.size); - safe_free(tmp); - } + /* + * If we read past the end of this request, move the remaining + * data to the beginning + */ + if (conn->in.offset > 0) + memmove(conn->in.buf, conn->in.buf + http->req_sz, conn->in.size); /* link */ for (H = &conn->chr; *H; H = &(*H)->next); *H = http;