groff-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[groff] 01/11: [me]: Abort if paper length too short.


From: G. Branden Robinson
Subject: [groff] 01/11: [me]: Abort if paper length too short.
Date: Fri, 13 Aug 2021 10:05:45 -0400 (EDT)

gbranden pushed a commit to branch master
in repository groff.

commit 7bfaf799c4822a99762cc30b0cf16ee89449621c
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Fri Aug 13 08:15:31 2021 +1000

    [me]: Abort if paper length too short.
    
    * tmac/e.tmac: Validate page length to prevent too-short paper formats
      from causing traps to call each other until the input stack overflows.
      The minimum is 14v.
    
      (check_page_length): Define new macro to perform the check.
    
      (bp, @p, sh, 2c, 1c): Call it from likely candidates (@p is internal
      and called by paragraphing macros).
    
      (pl): Intercept and wrap the `pl` request itself; check its setting
      immediately.
    
    Fixes <https://savannah.gnu.org/bugs/?61034>.
---
 ChangeLog   | 13 +++++++++++++
 tmac/e.tmac | 17 +++++++++++++++++
 2 files changed, 30 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index 51c6a14..9da1a7a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2021-08-13  G. Branden Robinson <g.branden.robinson@gmail.com>
+
+       * tmac/e.tmac: Validate page length to prevent too-short paper
+       formats from causing traps to call each other until the input
+       stack overflows.  The minimum is 14v.
+       (check_page_length): Define new macro to perform the check.
+       (bp, @p, sh, 2c, 1c): Call it from likely candidates (@p is
+       internal and called by paragraphing macros).
+       (pl): Intercept and wrap the `pl` request itself; check its
+       setting immediately.
+
+       Fixes <https://savannah.gnu.org/bugs/?61034>.
+
 2021-08-09  G. Branden Robinson <g.branden.robinson@gmail.com>
 
        * man/groff.7.man (Localization): Add section.
diff --git a/tmac/e.tmac b/tmac/e.tmac
index bba5db2..0a4e757 100644
--- a/tmac/e.tmac
+++ b/tmac/e.tmac
@@ -68,6 +68,11 @@
 .do if !r\\$1 .nr \\$1 0
 ..
 .
+.\" --- sanity check the page dimensions
+.do de check_page_length
+.if (\\n(.pu<14v) .ab e.tmac: cannot format short page length \\n(.pu
+..
+.
 .\" --- check whether grohtml needs end of title/heading
 .do de1 @html_check_need_title
 .if \\n[devtag-needs-end-of-title] \
@@ -493,6 +498,7 @@
 .if !'\*(.T'html' .rn bp @b    \" --- begin page
 .
 .de bp                 \" *** begin new page (overrides columns)
+.do check_page_length
 .nr $c \\n($m                  \" force new page, not new column
 .ie \\n(nl>0 \
 .      @b \\$1
@@ -516,6 +522,13 @@
 .      nr _L \\n(.l
 ..
 .
+.rn pl xP              \" *** save page length request
+.
+.de pl                 \" *** set page length
+.xP \\$1
+.do check_page_length
+..
+.
 .rn po @O              \" --- local page offset
 .
 .de po                 \" *** page offset
@@ -760,6 +773,7 @@
 ..
 .
 .de @p                 \" --- initialize for paragraph
+.do check_page_length
 .do check_need_title
 .if "\\n(.z"|e" .tm Line \\n(c. -- Unmatched continued equation
 .in \\n($iu+\\n(pou
@@ -779,6 +793,7 @@
 .
 .
 .de sh                 \" *** section heading
+.do check_page_length
 .fi
 .do check_need_title
 .if (\\n(si>0)&(\\n(si<1n) \
@@ -917,6 +932,7 @@
 .
 .
 .de 2c                 \" *** double columned output
+.do check_page_length
 .br
 .if \\n($m>1 \
 .      1c\"                    \" revert to 1c if already 2c
@@ -933,6 +949,7 @@
 ..
 .
 .de 1c                 \" *** single columned output
+.do check_page_length
 .br
 .nr $c 1
 .nr $m 1



reply via email to

[Prev in Thread] Current Thread [Next in Thread]