]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
xgettext: Perl: Avoid unbounded nesting_depth growth, part 4.
authorBruno Haible <bruno@clisp.org>
Mon, 18 Sep 2023 18:04:47 +0000 (20:04 +0200)
committerBruno Haible <bruno@clisp.org>
Tue, 19 Sep 2023 02:11:34 +0000 (04:11 +0200)
* 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}) {
  }
}
==========================================

gettext-tools/src/x-perl.c

index 4ab0a66d8f966f0f1e7dfd86041fbad0c6b79a6f..756d2a3834e92b1cfdc468e645697fcdac9c5dad 100644 (file)
@@ -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
       {