From 009b416d487632356e4065b3313118eb7dab4af0 Mon Sep 17 00:00:00 2001 From: Luigi Scarso Date: Sun, 9 May 2021 07:02:07 +0000 Subject: sync with upstream luatex; sync with upstream metapost. git-svn-id: svn://tug.org/texlive/trunk@59144 c570f23f-e606-0410-a88d-b1316a301751 --- Build/source/texk/web2c/mplibdir/ChangeLog | 4 ++++ Build/source/texk/web2c/mplibdir/mp.w | 8 ++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'Build/source/texk/web2c/mplibdir') 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 + * 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 * 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); -- cgit v1.2.3