From: Amos Jeffries Date: Thu, 9 Jul 2015 02:21:52 +0000 (-0700) Subject: Fix off-by-one errors in rev.14139 X-Git-Tag: merge-candidate-3-v1~52^2~3 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=81bf4a2c04ac1407aed721761940b386f2d1acbe;p=thirdparty%2Fsquid.git Fix off-by-one errors in rev.14139 --- diff --git a/src/client_side.cc b/src/client_side.cc index 739cffae53..2c03b56218 100644 --- a/src/client_side.cc +++ b/src/client_side.cc @@ -2240,7 +2240,7 @@ parseHttpRequest(ConnStateData *csd, const Http1::RequestParserPointer &hp) * requested url. may be rewritten later, so make extra room */ int url_sz = hp->requestUri().length() + Config.appendDomainLen + 5; http->uri = (char *)xcalloc(url_sz, 1); - xstrncpy(http->uri, hp->requestUri().rawContent(), hp->requestUri().length()); + xstrncpy(http->uri, hp->requestUri().rawContent(), hp->requestUri().length()+1); } result->flags.parsed_ok = 1; diff --git a/src/gopher.cc b/src/gopher.cc index 0347d2dae1..27e569ea54 100644 --- a/src/gopher.cc +++ b/src/gopher.cc @@ -273,8 +273,8 @@ gopher_request_parse(const HttpRequest * req, char *type_id, char *request) *type_id = typeId[0]; if (request) { - SBuf path = tok.remaining().substr(0, MAX_URL); - xstrncpy(request, path.rawContent(), path.length()); + SBuf path = tok.remaining().substr(0, MAX_URL-1); + xstrncpy(request, path.rawContent(), path.length()+1); /* convert %xx to char */ rfc1738_unescape(request); }