From: Joe Orton Date: Thu, 12 Sep 2024 08:36:55 +0000 (+0000) Subject: * modules/core/mod_macro.c (process_content): Return error if there's X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=43721ffceeaa4b373887d423a20984afca96707b;p=thirdparty%2Fapache%2Fhttpd.git * modules/core/mod_macro.c (process_content): Return error if there's enough not space to store the macro. Replaced MAX_STRING_LEN by sizeof(line). PR: 69258 Submitted by: Marc Stern Github: closes #479 git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1920588 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/changes-entries/pr69258.txt b/changes-entries/pr69258.txt new file mode 100644 index 00000000000..fb5f42bd46d --- /dev/null +++ b/changes-entries/pr69258.txt @@ -0,0 +1,3 @@ + *) mod_macro: Return an error if the expanded line would exceed the + maximum line length. PR 69258. + [Marc Stern ] diff --git a/modules/core/mod_macro.c b/modules/core/mod_macro.c index 544a287196a..24d6330d0d4 100644 --- a/modules/core/mod_macro.c +++ b/modules/core/mod_macro.c @@ -483,8 +483,13 @@ static const char *process_content(apr_pool_t * pool, for (i = 0; i < contents->nelts; i++) { const char *errmsg; /* copy the line and substitute macro parameters */ - apr_cpystrn(line, ((char **) contents->elts)[i], MAX_STRING_LEN); - errmsg = substitute_macro_args(line, MAX_STRING_LEN, + if (strlen(((char**)contents->elts)[i]) >= sizeof(line)) { + return apr_psprintf(pool, + "while processing line %d of macro '%s' (%s) %s", + i + 1, macro->name, macro->location, "macro too long"); + } + apr_cpystrn(line, ((char **) contents->elts)[i], sizeof(line)); + errmsg = substitute_macro_args(line, sizeof(line), macro, replacements, used); if (errmsg) { return apr_psprintf(pool,