You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by jo...@apache.org on 2026/10/20 19:29:55 UTC

svn commit: r1939296 - in httpd/httpd/trunk/modules: aaa filters

Author: jorton
Date: Tue Oct 20 19:29:54 2026
New Revision: 1939296

Log:
* modules/aaa/mod_auth_digest.c (set_shmem_size),
  modules/filters/mod_substitute.c (set_max_line_length): Use
  ap_size_parameter_parse().

Co-Authored-By: Claude Fable 5 <no...@anthropic.com>
GitHub: closes #851

Modified:
   httpd/httpd/trunk/modules/aaa/mod_auth_digest.c
   httpd/httpd/trunk/modules/filters/mod_substitute.c

Modified: httpd/httpd/trunk/modules/aaa/mod_auth_digest.c
==============================================================================
--- httpd/httpd/trunk/modules/aaa/mod_auth_digest.c	Tue Oct 20 19:29:29 2026	(r1939295)
+++ httpd/httpd/trunk/modules/aaa/mod_auth_digest.c	Tue Oct 20 19:29:54 2026	(r1939296)
@@ -555,35 +555,15 @@ static const char *set_uri_list(cmd_parm
 static const char *set_shmem_size(cmd_parms *cmd, void *config,
                                   const char *size_str)
 {
-    char *endptr;
     apr_off_t size;
     apr_size_t min;
+    apr_status_t rv;
 
-    if (apr_strtoff(&size, size_str, &endptr, 10) != APR_SUCCESS || size < 0) {
-        return apr_pstrcat(cmd->pool, "Invalid size in AuthDigestShmemSize: ",
-                          size_str, NULL);
-    }
-    if (*endptr == 'k' || *endptr == 'K') {
-        if (size > APR_INT64_MAX / 1024) {
-            return "AuthDigestShmemSize value is too large";
-        }
-        size *= 1024;
-        endptr++;
-    }
-    else if (*endptr == 'm' || *endptr == 'M') {
-        if (size > APR_INT64_MAX / (1024 * 1024)) {
-            return "AuthDigestShmemSize value is too large";
-        }
-        size *= 1024 * 1024;
-        endptr++;
-    }
-    else if (*endptr == 'b' || *endptr == 'B') {
-        endptr++;
-    }
-    while (apr_isspace(*endptr)) {
-        endptr++;
+    rv = ap_size_parameter_parse(size_str, &size);
+    if (rv == APR_ERANGE) {
+        return "AuthDigestShmemSize value is too large";
     }
-    if (*endptr != '\0') {
+    if (rv != APR_SUCCESS || size < 0) {
         return apr_pstrcat(cmd->pool, "Invalid size in AuthDigestShmemSize: ",
                           size_str, NULL);
     }

Modified: httpd/httpd/trunk/modules/filters/mod_substitute.c
==============================================================================
--- httpd/httpd/trunk/modules/filters/mod_substitute.c	Tue Oct 20 19:29:29 2026	(r1939295)
+++ httpd/httpd/trunk/modules/filters/mod_substitute.c	Tue Oct 20 19:29:54 2026	(r1939296)
@@ -773,40 +773,17 @@ static const char *set_pattern(cmd_parms
     return NULL;
 }
 
-#define KBYTE         1024
-#define MBYTE         1048576
-#define GBYTE         1073741824
 
 static const char *set_max_line_length(cmd_parms *cmd, void *cfg, const char *arg)
 {
     subst_dir_conf *dcfg = (subst_dir_conf *)cfg;
     apr_off_t max;
-    char *end;
     apr_status_t rv;
 
-    rv = apr_strtoff(&max, arg, &end, 10);
-    if (rv == APR_SUCCESS) {
-        if ((*end == 'K' || *end == 'k') && !end[1]) {
-            if (max > APR_INT64_MAX / KBYTE)
-                return "SubstituteMaxLineLength value too large";
-            max *= KBYTE;
-        }
-        else if ((*end == 'M' || *end == 'm') && !end[1]) {
-            if (max > APR_INT64_MAX / MBYTE)
-                return "SubstituteMaxLineLength value too large";
-            max *= MBYTE;
-        }
-        else if ((*end == 'G' || *end == 'g') && !end[1]) {
-            if (max > APR_INT64_MAX / GBYTE)
-                return "SubstituteMaxLineLength value too large";
-            max *= GBYTE;
-        }
-        else if (*end && /* neither empty nor [Bb] */
-                 ((*end != 'B' && *end != 'b') || end[1])) {
-            rv = APR_EGENERAL;
-        }
+    rv = ap_size_parameter_parse(arg, &max);
+    if (rv == APR_ERANGE) {
+        return "SubstituteMaxLineLength value too large";
     }
-
     if (rv != APR_SUCCESS || max < 0)
     {
         return "SubstituteMaxLineLength must be a non-negative integer optionally "