gbranden pushed a commit to branch master
in repository groff.

commit be37b22dfe0be1bd4d538b03cdcf8c62c8f10d02
Author: G. Branden Robinson <[email protected]>
AuthorDate: Tue Sep 29 01:09:09 2026 -0500

    [hpftodit]: Regression-test Savannah #68680.
    
    * src/utils/hpftodit/tests/avoids-heap-buffer-overflow.sh: Do it.
    
    * src/utils/hpftodit/hpftodit.am (hpftodit_TESTS): Run test.
    
      (TESTS, EXTRA_DIST): Wire `hpftodit_TESTS` into Automake test harness
      and ship this and any future hpftodit test scripts.
    
    Test fails at this commit.
---
 ChangeLog                                          | 10 +++++
 src/utils/hpftodit/hpftodit.am                     |  5 +++
 .../hpftodit/tests/avoids-heap-buffer-overflow.sh  | 52 ++++++++++++++++++++++
 3 files changed, 67 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index a75dc569e..1c24bea5d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2026-09-29  G. Branden Robinson <[email protected]>
+
+       [hpftodit]: Regression-test Savannah #68680.
+
+       * src/utils/hpftodit/tests/avoids-heap-buffer-overflow.sh: Do
+       it.
+       * src/utils/hpftodit/hpftodit.am (hpftodit_TESTS): Run test.
+       (TESTS, EXTRA_DIST): Wire `hpftodit_TESTS` into Automake test
+       harness and ship this and any future hpftodit test scripts.
+
 2026-09-24  G. Branden Robinson <[email protected]>
 
        * src/roff/troff/input.cpp (charinfo::dump): Clarify `pchar`
diff --git a/src/utils/hpftodit/hpftodit.am b/src/utils/hpftodit/hpftodit.am
index c6d8e1d08..b223f1673 100644
--- a/src/utils/hpftodit/hpftodit.am
+++ b/src/utils/hpftodit/hpftodit.am
@@ -20,6 +20,11 @@ hpftodit_SOURCES = \
   src/utils/hpftodit/hpftodit.h \
   src/utils/hpftodit/hpuni.cpp
 
+hpftodit_TESTS = \
+  src/utils/hpftodit/tests/avoids-heap-buffer-overflow.sh
+TESTS += $(hpftodit_TESTS)
+EXTRA_DIST += $(hpftodit_TESTS)
+
 # Local Variables:
 # mode: makefile-automake
 # fill-column: 72
diff --git a/src/utils/hpftodit/tests/avoids-heap-buffer-overflow.sh 
b/src/utils/hpftodit/tests/avoids-heap-buffer-overflow.sh
new file mode 100755
index 000000000..4379527ea
--- /dev/null
+++ b/src/utils/hpftodit/tests/avoids-heap-buffer-overflow.sh
@@ -0,0 +1,52 @@
+#!/bin/sh
+#
+# Copyright 2026 G. Branden Robinson
+#
+# groff is free software; you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free
+# Software Foundation, either version 3 of the License, or (at your
+# option) any later version.
+#
+# groff is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+hpftodit="${abs_top_builddir:-.}/hpftodit"
+
+# Regression-test Savannah #68680.
+#
+# hpftodit should manage memory responsibly.
+
+sandbox_dir=$(mktemp -d)
+if [ $? -ne 0 ]
+then
+    echo "cannot create temporary directory; skipping" >&2
+    exit 77 # skip
+fi
+
+# This method is based on a reproducer by Pavol Sloboda.
+
+tfm_file="$sandbox_dir"/test.tfm
+map_file="$sandbox_dir"/test.map
+out_file="$sandbox_dir"/TR # (not really) a description of Times Roman
+
+printf 'II\0\0\0\0\0\0\001\0\220\001\003\0\001\0\0\0\002\0\0\0' \
+    > "$tfm_file"
+printf '1\t0041\tu0041\n' > "$map_file"
+
+# We expect a controlled failure, not death by a signal.
+if ! "$hpftodit" "$tfm_file" "$map_file" "$out_file" 2>&1 \
+    | grep -q 'fatal error'
+then
+    echo "test failed; files left in \"$sandbox_dir\"" >&2
+    exit 1
+fi
+
+rm "$tfm_file" "$map_file" "$out_file"
+rmdir "$sandbox_dir"
+
+# vim:set autoindent expandtab shiftwidth=4 tabstop=4 textwidth=72:

_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit

Reply via email to