From: Bruno Haible Date: Sun, 12 Mar 2023 12:33:30 +0000 (+0100) Subject: xgettext: In language C#, avoid a crash due to a too small buffer. X-Git-Tag: v0.22~115 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7886dcc16749f40243243a27e1a1e94d176e793d;p=thirdparty%2Fgettext.git xgettext: In language C#, avoid a crash due to a too small buffer. * gettext-tools/src/x-csharp.c (phase3_pushback): Increase size to 10. * gettext-tools/tests/xgettext-csharp-9: New file. * gettext-tools/tests/Makefile.am (TESTS): Add it. --- diff --git a/gettext-tools/src/x-csharp.c b/gettext-tools/src/x-csharp.c index 44cc774e3..1985c084f 100644 --- a/gettext-tools/src/x-csharp.c +++ b/gettext-tools/src/x-csharp.c @@ -445,7 +445,7 @@ phase2_ungetc (int c) /* Line number defined in terms of phase3. */ static int logical_line_number; -static int phase3_pushback[9]; +static int phase3_pushback[10]; static int phase3_pushback_length; /* Read the next Unicode UCS-4 character from the input file, mapping diff --git a/gettext-tools/tests/Makefile.am b/gettext-tools/tests/Makefile.am index cfbc7179c..b4bb3eba3 100644 --- a/gettext-tools/tests/Makefile.am +++ b/gettext-tools/tests/Makefile.am @@ -96,7 +96,7 @@ TESTS = gettext-1 gettext-2 \ xgettext-c-stackovfl-1 xgettext-c-stackovfl-2 \ xgettext-csharp-1 xgettext-csharp-2 xgettext-csharp-3 \ xgettext-csharp-4 xgettext-csharp-5 xgettext-csharp-6 \ - xgettext-csharp-7 xgettext-csharp-8 \ + xgettext-csharp-7 xgettext-csharp-8 xgettext-csharp-9 \ xgettext-csharp-stackovfl-1 xgettext-csharp-stackovfl-2 \ xgettext-csharp-stackovfl-3 xgettext-csharp-stackovfl-4 \ xgettext-desktop-1 xgettext-desktop-2 \ diff --git a/gettext-tools/tests/xgettext-csharp-9 b/gettext-tools/tests/xgettext-csharp-9 new file mode 100755 index 000000000..35fbaca0f --- /dev/null +++ b/gettext-tools/tests/xgettext-csharp-9 @@ -0,0 +1,13 @@ +#! /bin/sh +. "${srcdir=.}/init.sh"; path_prepend_ . ../src + +# Test C# support: large pushback. + +cat <<\EOF > xg-cs-9.cs +x\U00000000 +EOF + +: ${XGETTEXT=xgettext} +${XGETTEXT} --omit-header --no-location -d xg-cs-9.tmp xg-cs-9.cs || Exit 1 + +exit 0