gbranden pushed a commit to branch master
in repository groff.
commit 3286e0681805eca77ac7518c8cdff0beb54eabb6
Author: G. Branden Robinson <[email protected]>
AuthorDate: Fri Jul 24 15:51:10 2026 -0500
[grops]: Fix Savannah #68560.
* src/devices/grops/ps.cpp (ps_printer::do_import): Revise to avoid
overreading heap by one byte with certain ill-formed arguments to the
`import` device extension command. Recast error diagnostic to report
the full contents of the invalid argument and characterize it simply
as "invalid" due to non-numeric contents. Also clarify the language
of these diagnostics. The grammar of "trout"/"grout" is such that the
device control command reads, to the end of the line, one big
"argument" containing space-delimited parameters.
Fixes <https://savannah.gnu.org/bugs/?68560>. Thanks to Bruno Haible
for the concurrent discovery. Problem introduced by me in commit
9f050b7ed7, 7 May.
With this commit, for me on my system (GNU/Linux amd64 using GCC
10.2.1), groff now builds and runs its test suite successfully with the
following compiler options.
-fsanitize=address
-fsanitize-undefined-trap-on-error
-fsanitize=signed-integer-overflow
-fsanitize=undefined
However we can't employ the full power of ASAN yet. I'm using
`ASAN_OPTIONS="detect_leaks=0 abort_on_error=1
allocator_may_return_null=1 alloc_dealloc_mismatch=0"`.
I'm informed that Clang's ASAN is more sensitive. However I'm unable to
use Clang 11.0.1 to build groff in this same environment because it
doesn't get along well with Gnulib's <stdckdint.h> implementation and
our attempt to hew to ISO C++98; it blows up complaining that the `long
long` data type demands C++11.
---
ChangeLog | 16 ++++++++++++++++
src/devices/grops/ps.cpp | 26 ++++++++++++++++----------
2 files changed, 32 insertions(+), 10 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index cacfd1459..997cd6f83 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2026-07-24 G. Branden Robinson <[email protected]>
+
+ * src/devices/grops/ps.cpp (ps_printer::do_import): Revise to
+ avoid overreading heap by one byte with certain ill-formed
+ arguments to the `import` device extension command. Recast
+ error diagnostic to report the full contents of the invalid
+ argument and characterize it simply as "invalid" due to
+ non-numeric contents. Also clarify the language of these
+ diagnostics. The grammar of "trout"/"grout" is such that the
+ device control command reads, to the end of the line, one big
+ "argument" containing space-delimited parameters.
+
+ Fixes <https://savannah.gnu.org/bugs/?68560>. Thanks to Bruno
+ Haible for the concurrent discovery. Problem introduced by me
+ in commit 9f050b7ed7, 7 May.
+
2026-07-24 G. Branden Robinson <[email protected]>
* src/devices/grops/ps.cpp (ps_printer::do_import): Fix
diff --git a/src/devices/grops/ps.cpp b/src/devices/grops/ps.cpp
index d937d3615..d4aa564c8 100644
--- a/src/devices/grops/ps.cpp
+++ b/src/devices/grops/ps.cpp
@@ -1852,6 +1852,8 @@ void ps_printer::do_import(char *arg, const environment
*env)
while ((' ' == *arg) || ('\n' == *arg))
arg++;
char *p;
+ // Skip validation of first argument, a file name.
+ // XXX: This means we can't import file names with spaces in them.
for (p = arg; (*p != '\0') && (*p != ' ') && (*p != '\n'); p++)
;
if (*p != '\0')
@@ -1866,26 +1868,30 @@ void ps_printer::do_import(char *arg, const environment
*env)
parms[nparms++] = int(n);
p = end;
}
- if ((csalpha(*p) && (p[1] == '\0'))
- || (p[1] == ' ')
- || (p[1] == '\n')) {
- error("scaling unit '%1' not allowed in argument to"
- "device extension command 'import'", p[1]);
+ size_t idx = 0;
+ if (strlen(p) > 1)
+ idx = 1;
+ if (!csdigit(p[idx])
+ && (p[idx] != ' ')
+ && (p[idx] != '\n')
+ && (p[idx] != '\0')) {
+ error("invalid numeric parameters '%1'"
+ " in device extension command 'import' argument", p);
return;
}
while ((' ' == *p) || ('\n' == *p))
p++;
if (nparms < 5) {
if (*p == '\0')
- error("too few arguments to device extension command 'import'");
+ error("too few parameters in device extension command 'import'");
else
- error("invalid argument '%1'"
- " to device extension command 'import'", p);
+ error("invalid parameter '%1'"
+ " in device extension command 'import' argument", p);
return;
}
if (*p != '\0') {
- error("superfluous argument '%1'"
- " to device extension command 'import'", p);
+ error("superfluous parameter '%1'"
+ " in device extension command 'import' argument", p);
return;
}
int llx = parms[0];
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit