]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Be more careful when dealing with limited buffers.
authorAndré Malo <nd@apache.org>
Thu, 27 Feb 2003 03:47:37 +0000 (03:47 +0000)
committerAndré Malo <nd@apache.org>
Thu, 27 Feb 2003 03:47:37 +0000 (03:47 +0000)
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

src/modules/standard/mod_rewrite.c

index b6f4cf28d75c21a46634629f69a27a62ebcc8fea..fdac21eae3a012209d881c9d0301242a0e79f3ca 100644 (file)
@@ -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++;