From: Bruno Haible Date: Mon, 18 Sep 2023 18:04:47 +0000 (+0200) Subject: xgettext: Perl: Avoid unbounded nesting_depth growth, part 4. X-Git-Tag: v0.22.1~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=92d6e980b9784276171e580b57d132adba317882;p=thirdparty%2Fgettext.git xgettext: Perl: Avoid unbounded nesting_depth growth, part 4. * gettext-tools/src/x-perl.c: Improve parsing of array dereferences. (extract_variable): After parsing a braced {variable_name}, increment varbody_length, so as to not parse the following character. If this character is a closing parenthesis, is would disturb the enclosing extract_balanced call. Test case: ========================================== sub in_multi_expanded($) { if (@{$self}) { } } ========================================== --- diff --git a/gettext-tools/src/x-perl.c b/gettext-tools/src/x-perl.c index 4ab0a66d8..756d2a383 100644 --- a/gettext-tools/src/x-perl.c +++ b/gettext-tools/src/x-perl.c @@ -1432,6 +1432,13 @@ extract_variable (message_list_ty *mlp, token_ty *tp, int first) return; } buffer[bufpos++] = c; + ++varbody_length; + if (bufpos >= bufmax) + { + bufmax = 2 * bufmax + 10; + buffer = xrealloc (buffer, bufmax); + } + buffer[bufpos++] = '}'; } else {