You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by yl...@apache.org on 2022/01/20 12:47:02 UTC

svn commit: r1897248 - /httpd/httpd/trunk/server/util_pcre.c

Author: ylavic
Date: Thu Jan 20 12:47:02 2022
New Revision: 1897248

URL: http://svn.apache.org/viewvc?rev=1897248&view=rev
Log:
ap_regex: Follow up to r1897244: Fix pmatch overflow and returned value at limits.

Don't write to pmatch[nlimit:] when ncaps > nlimit, rc should not exceed nmatch
either as before r1897244.


Modified:
    httpd/httpd/trunk/server/util_pcre.c

Modified: httpd/httpd/trunk/server/util_pcre.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/util_pcre.c?rev=1897248&r1=1897247&r2=1897248&view=diff
==============================================================================
--- httpd/httpd/trunk/server/util_pcre.c (original)
+++ httpd/httpd/trunk/server/util_pcre.c Thu Jan 20 12:47:02 2022
@@ -428,10 +428,8 @@ AP_DECLARE(int) ap_regexec_len(const ap_
 
     if (rc >= 0) {
         apr_size_t n = rc, i;
-        if (rc == 0)
-            rc = ncaps; /* All captured slots were filled in */
-        else if (n > nmatch)
-            n = nmatch;
+        if (n == 0 || n > nmatch)
+            rc = n = nmatch; /* All capture slots were filled in */
         for (i = 0; i < n; i++) {
             pmatch[i].rm_so = ovector[i * 2];
             pmatch[i].rm_eo = ovector[i * 2 + 1];