diff options
author | Bruno Haible <bruno@clisp.org> | 2023-03-13 00:51:07 +0100 |
---|---|---|
committer | Bruno Haible <bruno@clisp.org> | 2023-03-14 02:57:28 +0100 |
commit | 3904fddd401dc6b22bffedcc8668f144fe467494 (patch) | |
tree | 2e770a965fe7b7654dc7dc5210f59c9a4066d5ab | |
parent | ff78c835ad8aa8a7f00d237eaa4b3f369edcbe1d (diff) | |
download | gettext-3904fddd401dc6b22bffedcc8668f144fe467494.tar.gz |
Fix lisp-format, scheme-format: Fix a memory corruption bug.
* gettext-tools/src/format-lisp.c (make_repeated_list): Access the correct
array.
* gettext-tools/src/format-scheme.c (make_repeated_list): Likewise.
* gettext-tools/tests/xgettext-lisp-3: New file.
* gettext-tools/tests/xgettext-scheme-5: New file.
* gettext-tools/tests/Makefile.am (TESTS): Add them.
-rw-r--r-- | gettext-tools/src/format-lisp.c | 5 | ||||
-rw-r--r-- | gettext-tools/src/format-scheme.c | 4 | ||||
-rw-r--r-- | gettext-tools/tests/Makefile.am | 4 | ||||
-rwxr-xr-x | gettext-tools/tests/xgettext-lisp-3 | 24 | ||||
-rwxr-xr-x | gettext-tools/tests/xgettext-scheme-5 | 24 |
5 files changed, 54 insertions, 7 deletions
diff --git a/gettext-tools/src/format-lisp.c b/gettext-tools/src/format-lisp.c index 94194dbef..f69c880e4 100644 --- a/gettext-tools/src/format-lisp.c +++ b/gettext-tools/src/format-lisp.c @@ -1,6 +1,5 @@ /* Lisp format strings. - Copyright (C) 2001-2004, 2006-2007, 2009, 2014, 2019 Free Software - Foundation, Inc. + Copyright (C) 2001-2004, 2006-2007, 2009, 2014, 2019, 2023 Free Software Foundation, Inc. Written by Bruno Haible <haible@clisp.cons.org>, 2001. This program is free software: you can redistribute it and/or modify @@ -2125,7 +2124,7 @@ make_repeated_list (struct format_arg_list *sublist, unsigned int period) for (i = 0; i < sublist->initial.count; i++) tmp.element[i] = sublist->initial.element[i]; for (j = 0; j < sublist->repeated.count; i++, j++) - tmp.element[i] = sublist->initial.element[j]; + tmp.element[i] = sublist->repeated.element[j]; tmp.length = sublist->initial.length + sublist->repeated.length; srcseg = &tmp; diff --git a/gettext-tools/src/format-scheme.c b/gettext-tools/src/format-scheme.c index 9958a475e..184ce5cac 100644 --- a/gettext-tools/src/format-scheme.c +++ b/gettext-tools/src/format-scheme.c @@ -1,5 +1,5 @@ /* Scheme format strings. - Copyright (C) 2001-2007, 2009, 2014, 2019 Free Software Foundation, Inc. + Copyright (C) 2001-2007, 2009, 2014, 2019, 2023 Free Software Foundation, Inc. Written by Bruno Haible <haible@clisp.cons.org>, 2001. This program is free software: you can redistribute it and/or modify @@ -2147,7 +2147,7 @@ make_repeated_list (struct format_arg_list *sublist, unsigned int period) for (i = 0; i < sublist->initial.count; i++) tmp.element[i] = sublist->initial.element[i]; for (j = 0; j < sublist->repeated.count; i++, j++) - tmp.element[i] = sublist->initial.element[j]; + tmp.element[i] = sublist->repeated.element[j]; tmp.length = sublist->initial.length + sublist->repeated.length; srcseg = &tmp; diff --git a/gettext-tools/tests/Makefile.am b/gettext-tools/tests/Makefile.am index fcb60d81d..034296659 100644 --- a/gettext-tools/tests/Makefile.am +++ b/gettext-tools/tests/Makefile.am @@ -121,7 +121,7 @@ TESTS = gettext-1 gettext-2 \ xgettext-javascript-stackovfl-7 xgettext-javascript-stackovfl-8 \ xgettext-librep-1 xgettext-librep-2 xgettext-librep-3 \ xgettext-librep-stackovfl-1 xgettext-librep-stackovfl-2 \ - xgettext-lisp-1 xgettext-lisp-2 \ + xgettext-lisp-1 xgettext-lisp-2 xgettext-lisp-3 \ xgettext-lisp-stackovfl-1 xgettext-lisp-stackovfl-2 \ xgettext-lua-1 xgettext-lua-2 xgettext-lua-3 \ xgettext-lua-stackovfl-1 xgettext-lua-stackovfl-2 \ @@ -145,7 +145,7 @@ TESTS = gettext-1 gettext-2 \ xgettext-python-stackovfl-3 xgettext-python-stackovfl-4 \ xgettext-ruby-1 \ xgettext-scheme-1 xgettext-scheme-2 xgettext-scheme-3 \ - xgettext-scheme-4 \ + xgettext-scheme-4 xgettext-scheme-5 \ xgettext-scheme-stackovfl-1 xgettext-scheme-stackovfl-2 \ xgettext-sh-1 xgettext-sh-2 xgettext-sh-3 xgettext-sh-4 xgettext-sh-5 \ xgettext-sh-6 xgettext-sh-7 \ diff --git a/gettext-tools/tests/xgettext-lisp-3 b/gettext-tools/tests/xgettext-lisp-3 new file mode 100755 index 000000000..901c245a7 --- /dev/null +++ b/gettext-tools/tests/xgettext-lisp-3 @@ -0,0 +1,24 @@ +#! /bin/sh +. "${srcdir=.}/init.sh"; path_prepend_ . ../src + +# Test Lisp support: lisp-format string with a loop. + +cat <<EOF > xg-ls-3.lisp +(gettext "~{~*~}") +EOF + +: ${XGETTEXT=xgettext} +${XGETTEXT} --omit-header --no-location -d xg-ls-3.tmp xg-ls-3.lisp || Exit 1 +LC_ALL=C tr -d '\r' < xg-ls-3.tmp.po > xg-ls-3.po || Exit 1 + +cat <<EOF > xg-ls-3.ok +#, lisp-format +msgid "~{~*~}" +msgstr "" +EOF + +: ${DIFF=diff} +${DIFF} xg-ls-3.ok xg-ls-3.po +result=$? + +exit $result diff --git a/gettext-tools/tests/xgettext-scheme-5 b/gettext-tools/tests/xgettext-scheme-5 new file mode 100755 index 000000000..9d9284585 --- /dev/null +++ b/gettext-tools/tests/xgettext-scheme-5 @@ -0,0 +1,24 @@ +#! /bin/sh +. "${srcdir=.}/init.sh"; path_prepend_ . ../src + +# Test Scheme support: scheme-format string with a loop. + +cat <<EOF > xg-sc-5.scm +(_ "~{~*~}") +EOF + +: ${XGETTEXT=xgettext} +${XGETTEXT} -k_ --omit-header --no-location -d xg-sc-5.tmp xg-sc-5.scm || Exit 1 +LC_ALL=C tr -d '\r' < xg-sc-5.tmp.po > xg-sc-5.po || Exit 1 + +cat <<EOF > xg-sc-5.ok +#, scheme-format +msgid "~{~*~}" +msgstr "" +EOF + +: ${DIFF=diff} +${DIFF} xg-sc-5.ok xg-sc-5.po +result=$? + +exit $result |