diff options
Diffstat (limited to 'Build/source/texk/web2c/tex.ch')
-rw-r--r-- | Build/source/texk/web2c/tex.ch | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/Build/source/texk/web2c/tex.ch b/Build/source/texk/web2c/tex.ch index 4b0a0d443b9..2626b237831 100644 --- a/Build/source/texk/web2c/tex.ch +++ b/Build/source/texk/web2c/tex.ch @@ -282,6 +282,9 @@ versions of the program. @!sup_hyph_size = ssup_hyph_size; @!inf_hyph_size = iinf_hyphen_size; {Must be not less than |hyph_prime|!} + +@!inf_expand_depth = 10; +@!sup_expand_depth = 10000000; @z @x [1.12] l.427 - Constants that are WEB numeric macros. @@ -594,6 +597,7 @@ tini@/ @!save_size:integer; {space for saving values outside of current group; must be at most |max_halfword|} @!dvi_buf_size:integer; {size of the output buffer; must be a multiple of 8} +@!expand_depth:integer; {limits recursive calls to the |expand| procedure} @!parse_first_line_p:c_int_type; {parse the first line for options} @!file_line_error_style_p:c_int_type; {format messages as file:line:error} @!eight_bit_p:c_int_type; {make all characters printable by default} @@ -1814,6 +1818,46 @@ end while k < limit do begin print_buffer(k) end; @z +@x [25.366] expansion depth check +The |expand| subroutine is used when |cur_cmd>max_command|. It removes a +@y +@ Sometimes, recursive calls to the following |expand| routine may +cause exhaustion of the run-time calling stack, resulting in +forced execution stops by the operating system. To diminish the chance +of this happening, a counter is used to keep track of the recursion +depth, in conjunction with a constant called |expand_depth|. + +This does not catch all possible infinite recursion loops, just the ones +that exhaust the application calling stack. The actual maximum value of +|expand_depth| is outside of our control, but the initial setting of +|10000| should be enough to prevent problems. +@^system dependencies@> + +@<Global...@>= +expand_depth_count:integer; + +@ @<Set init...@>= +expand_depth_count:=0; + +@ The |expand| subroutine is used when |cur_cmd>max_command|. It removes a +@z + +@x [25.366] +begin cv_backup:=cur_val; cvl_backup:=cur_val_level; radix_backup:=radix; +@y +begin +incr(expand_depth_count); +if expand_depth_count>=expand_depth then overflow("expansion depth",expand_depth); +cv_backup:=cur_val; cvl_backup:=cur_val_level; radix_backup:=radix; +@z + +@x [25.366] +cur_order:=co_backup; link(backup_head):=backup_backup; +@y +cur_order:=co_backup; link(backup_head):=backup_backup; +decr(expand_depth_count); +@z + @x [25.372] - encTeX: we need to distinguish \endcsname and \endmubyte if cur_cmd<>end_cs_name then @<Complain about missing \.{\\endcsname}@>; @y @@ -4571,6 +4615,7 @@ begin @!{|start_here|} setup_bound_var (50)('half_error_line')(half_error_line); setup_bound_var (79)('max_print_line')(max_print_line); setup_bound_var (0)('hash_extra')(hash_extra); + setup_bound_var (10000)('expand_depth')(expand_depth); const_chk (mem_bot); const_chk (main_memory); |