URL: <https://savannah.gnu.org/bugs/?68817>
Summary: [PATCH] [troff] assertion failure when `als` request
given invalid first identifier
Group: GNU roff
Submitter: gbranden
Submitted: Thu 22 Oct 2026 03:11:32 PM UTC
Category: Formatter
Severity: 4 - Important
Item Group: Crash/Unresponsive
Status: In Progress
Privacy: Public
Assigned to: gbranden
Open/Closed: Open
Discussion Lock: Unlocked
Planned Release: None
_______________________________________________________
Follow-up Comments:
-------------------------------------------------------
Date: Thu 22 Oct 2026 03:11:32 PM UTC By: G. Branden Robinson <gbranden>
$ printf '.als \002\n' | ~/groff-1.24.2/bin/groff
troff:<standard input>:1: error: character code 2 is not allowed in an
identifier
troff: ../src/roff/troff/input.cpp:5667: void alias_macro(): Assertion `s1 !=
0' failed.
/home/branden/groff-1.24.2/bin/groff: error: troff: Aborted (core dumped)
The test and the fix:
commit 5e76491b4ee82464f99f10834086c4dfa7d27452
Author: G. Branden Robinson <[email protected]>
Date: Thu Oct 22 10:09:30 2026 -0500
XXX [groff]: Regression-test Savannah #XXX.
diff --git a/src/roff/groff/groff.am b/src/roff/groff/groff.am
index a9e405f8e..4ca89b631 100644
--- a/src/roff/groff/groff.am
+++ b/src/roff/groff/groff.am
@@ -103,6 +103,7 @@ groff_TESTS = \
src/roff/groff/tests/driver-C-and-G-options-work.sh \
src/roff/groff/tests/dt-request-works.sh \
src/roff/groff/tests/dvi-device-smoke-test.sh \
+ src/roff/groff/tests/error-als-request-given-bogus-arguments.sh \
src/roff/groff/tests/error-close-request-given-empty-argument.sh \
src/roff/groff/tests/error-defcolor-request-given-bogus-arguments.sh \
src/roff/groff/tests/error-dt-request-given-bogus-arguments.sh \
diff --git a/src/roff/groff/tests/error-als-request-given-bogus-arguments.sh
b/src/roff/groff/tests/error-als-request-given-bogus-arguments.sh
new file mode 100755
index 000000000..873fd4d3b
--- /dev/null
+++ b/src/roff/groff/tests/error-als-request-given-bogus-arguments.sh
@@ -0,0 +1,37 @@
+#!/bin/sh
+#
+# Copyright 2026 G. Branden Robinson
+#
+# This file is part of groff, the GNU roff typesetting system.
+#
+# 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/>.
+
+groff="${abs_top_builddir:-.}/test-groff"
+
+fail=
+
+wail () {
+ echo "...FAILED"
+ fail=yes
+}
+
+echo "checking that 'als' request rejects invalid first argument" >&2
+output=$(printf '.als \002\n' | "$groff" -T ascii) || wail
+
+echo "checking that 'als' request rejects invalid second argument" >&2
+output=$(printf '.als foo \002\n' | "$groff" -T ascii) || wail
+
+test -z "$fail"
+
+# vim:set autoindent expandtab shiftwidth=4 tabstop=4 textwidth=72:
commit 0242e6b2835929614c1c96541ea7235ff2f764e2
Author: G. Branden Robinson <[email protected]>
Date: Thu Oct 22 10:10:03 2026 -0500
XXX [troff]: Fix Savannah #XXX.
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index 13f6a4558..9a9357d48 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -5887,18 +5887,19 @@ static void alias_macro() // .als
return;
}
symbol s1 = read_identifier();
- assert(s1 != 0 /* nullptr */);
- if (!s1.is_null()) {
- symbol s2 = read_identifier();
- if (s2.is_null())
- warning(WARN_MISSING, "name aliasing request expects identifier"
- " of existing request, macro, string, or diversion as"
- " second argument");
- else {
- if (!request_dictionary.alias(s1, s2))
- error("cannot alias undefined name '%1'", s2.contents());
- }
+ if (s1.is_null()) {
+ // The identifier was garbage, like `a\&b`.
+ skip_line();
+ return;
+ }
+ symbol s2 = read_identifier();
+ if (s2.is_null()) {
+ // The identifier was garbage, like `a\&b`.
+ skip_line();
+ return;
}
+ if (!request_dictionary.alias(s1, s2))
+ error("cannot alias undefined name '%1'", s2.contents());
skip_line();
}
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?68817>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
signature.asc
Description: PGP signature
