diff options
author | Robert James Kaes <rjkaes@users.sourceforge.net> | 2003-06-06 16:14:50 +0000 |
---|---|---|
committer | Robert James Kaes <rjkaes@users.sourceforge.net> | 2003-06-06 16:14:50 +0000 |
commit | b081019d5ab9a0247f7d6fb5592efa4b8f49b81b (patch) | |
tree | 406dcb2b4f33990526725e0866850378930c80bb | |
parent | c2240df6161d0b83b220d23bb4baa15a7fb7fc2f (diff) | |
download | tinyproxy-b081019d5ab9a0247f7d6fb5592efa4b8f49b81b.tar.gz tinyproxy-b081019d5ab9a0247f7d6fb5592efa4b8f49b81b.zip |
(connect_to_upstream): Fixed an off-by-one error in the snprintf()
call used to build the URL for the upstream proxy. [Patch suggested by
David T. Pierso]
-rw-r--r-- | src/reqs.c | 11 |
1 files changed, 6 insertions, 5 deletions
@@ -1,4 +1,4 @@ -/* $Id: reqs.c,v 1.102 2003-06-02 21:55:14 rjkaes Exp $ +/* $Id: reqs.c,v 1.103 2003-06-06 16:14:50 rjkaes Exp $ * * This is where all the work in tinyproxy is actually done. Incoming * connections have a new child created for them. The child then @@ -1437,9 +1437,9 @@ connect_to_upstream(struct conn_s *connptr, struct request_s *request) * method and path. */ if (connptr->connect_method) { - len = strlen(request->host) + 6; + len = strlen(request->host) + 7; - combined_string = safemalloc(len + 1); + combined_string = safemalloc(len); if (!combined_string) { return -1; } @@ -1448,7 +1448,7 @@ connect_to_upstream(struct conn_s *connptr, struct request_s *request) request->port); } else { len = strlen(request->host) + strlen(request->path) + 14; - combined_string = safemalloc(len + 1); + combined_string = safemalloc(len); if (!combined_string) { return -1; } @@ -1457,7 +1457,8 @@ connect_to_upstream(struct conn_s *connptr, struct request_s *request) request->port, request->path); } - safefree(request->path); + if (request->path) + safefree(request->path); request->path = combined_string; return establish_http_connection(connptr, request); |