summaryrefslogtreecommitdiff
path: root/Build/source/texk/web2c/mplibdir
diff options
context:
space:
mode:
authorLuigi Scarso <luigi.scarso@gmail.com>2021-05-09 07:02:07 +0000
committerLuigi Scarso <luigi.scarso@gmail.com>2021-05-09 07:02:07 +0000
commit009b416d487632356e4065b3313118eb7dab4af0 (patch)
treef8aed0ab5ec96817a6911a18f8fe864842815592 /Build/source/texk/web2c/mplibdir
parentd408beb505856c02bbae6121e29e4cb285077719 (diff)
sync with upstream luatex; sync with upstream metapost.
git-svn-id: svn://tug.org/texlive/trunk@59144 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/web2c/mplibdir')
-rw-r--r--Build/source/texk/web2c/mplibdir/ChangeLog4
-rw-r--r--Build/source/texk/web2c/mplibdir/mp.w8
2 files changed, 10 insertions, 2 deletions
diff --git a/Build/source/texk/web2c/mplibdir/ChangeLog b/Build/source/texk/web2c/mplibdir/ChangeLog
index 3a421c77907..1ad10d39285 100644
--- a/Build/source/texk/web2c/mplibdir/ChangeLog
+++ b/Build/source/texk/web2c/mplibdir/ChangeLog
@@ -1,3 +1,7 @@
+2021-05-09 Luigi Scarso <luigi.scarso@gmail.com>
+ * Impose mp->stack_size < 1001 in @d push_input to avoid stack overflow
+ due infinite recursion of macro expansion (thanks to A. Kakuto).
+
2021-04-10 Luigi Scarso <luigi.scarso@gmail.com>
* Metapost version 2.01 (needed to mark the patch mpx_copy_mpto).
diff --git a/Build/source/texk/web2c/mplibdir/mp.w b/Build/source/texk/web2c/mplibdir/mp.w
index 2a28640c215..acb64feed7f 100644
--- a/Build/source/texk/web2c/mplibdir/mp.w
+++ b/Build/source/texk/web2c/mplibdir/mp.w
@@ -18136,11 +18136,15 @@ new level (having, initially, the same properties as the old).
@d push_input { /* enter a new input level, save the old */
if ( mp->input_ptr>mp->max_in_stack ) {
mp->max_in_stack=mp->input_ptr;
- if ( mp->input_ptr==mp->stack_size ) {
+ /* The mp->stack_size < 1001 condition is necessary to prevent stack overflow due infinite recursion. */
+ if ( mp->input_ptr==mp->stack_size && mp->stack_size < 1001) {
int l = (mp->stack_size+(mp->stack_size/4));
XREALLOC(mp->input_stack, l, in_state_record);
mp->stack_size = l;
- }
+ } else {
+ fprintf(stderr, "input stack overflow\n");
+ exit(EXIT_FAILURE);
+ }
}
mp->input_stack[mp->input_ptr]=mp->cur_input; /* stack the record */
incr(mp->input_ptr);