From: André Malo Date: Thu, 27 Feb 2003 03:47:37 +0000 (+0000) Subject: Be more careful when dealing with limited buffers. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5249ca05be75668a7d3ce7eadefe340f348f77e5;p=thirdparty%2Fapache%2Fhttpd.git Be more careful when dealing with limited buffers. Oh my, I forgot it again. but now: Reviewed by: Cliff Woolley, Bill Stoddard git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/1.3.x@98810 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/modules/standard/mod_rewrite.c b/src/modules/standard/mod_rewrite.c index b6f4cf28d75..fdac21eae3a 100644 --- a/src/modules/standard/mod_rewrite.c +++ b/src/modules/standard/mod_rewrite.c @@ -3937,8 +3937,8 @@ static char *subst_prefix_path(request_rec *r, char *input, char *match, output = input; /* first create a match string which always has a trailing slash */ - l = ap_cpystrn(matchbuf, match, sizeof(matchbuf)) - matchbuf; - if (matchbuf[l-1] != '/') { + l = ap_cpystrn(matchbuf, match, sizeof(matchbuf) - 1) - matchbuf; + if (!l || matchbuf[l-1] != '/') { matchbuf[l] = '/'; matchbuf[l+1] = '\0'; l++; @@ -3949,8 +3949,8 @@ static char *subst_prefix_path(request_rec *r, char *input, char *match, output = ap_pstrdup(r->pool, output+l); /* and now add the base-URL as replacement prefix */ - l = ap_cpystrn(substbuf, subst, sizeof(substbuf)) - substbuf; - if (substbuf[l-1] != '/') { + l = ap_cpystrn(substbuf, subst, sizeof(substbuf) - 1) - substbuf; + if (!l || substbuf[l-1] != '/') { substbuf[l] = '/'; substbuf[l+1] = '\0'; l++;