]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
From: Henrik Nordstrom <hno@hem.passagen.se>
authorwessels <>
Thu, 1 Jan 1998 06:55:12 +0000 (06:55 +0000)
committerwessels <>
Thu, 1 Jan 1998 06:55:12 +0000 (06:55 +0000)
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.

src/client_side.cc

index 860f41838133c28507e9b487aef9ca786ec62ebe..9d58e2e2d80ecda83d57f08b506144d911fb056c 100644 (file)
@@ -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;