Hi Nick,
Nick Bowler <[email protected]> writes:
> It seems that recently the GNU coreutils programs now have unreadable
> --help output due to printing large amounts of terminal control
> sequences which are not interpreted as expected by e.g. GNU mach, and
> probably a lot of other terminals since they seem to be printed
> unconditionally (even when redirecting to a file...)
>
> I found the configure options --disable-bold-man-page-references and
> --disable-manual-url, but unfortunately these do not actually work:
> when these options are used, everything gets built OK but then chroot
> --help segfaults. The build ultimately fails when it runs help2man on
> chroot.
>
> This appears to be because the fallback call to vprintf in oprintf_
> passes an invalid va_list so it does not work at all. The following
> patch corrects this problem:
>
> --- coreutils-9.12/src/system.h.orig
> +++ coreutils-9.12/src/system.h
> @@ -734,7 +734,9 @@
>
> if (buflen < 0)
> {
> + va_start (args, message);
> vprintf (message, args);
> + va_end (args);
> return;
> }
Thank you for the report and the patch.
I pushed that patch in your name, and the second attached patch, which
adds a NEWS entry.
The rationale for including the links when piped or redirected was so
that you could use the links when piping into 'less', for example.
I'm leaving this report open for now, since I think we may want to
reconsider this due to this report and one or two similar ones.
Unfortunately, I am unable to link them since I haven't been able to
connect to bugs.gnu.org for the past week, except for a few hours
yesterday. :(
Collin
>From d66cf56e25e3fa7d120c0fab2ce793c51763effb Mon Sep 17 00:00:00 2001
Message-ID: <d66cf56e25e3fa7d120c0fab2ce793c51763effb.1791519677.git.collin.fu...@gmail.com>
From: Nick Bowler <[email protected]>
Date: Thu, 8 Oct 2026 20:33:53 -0700
Subject: [PATCH 1/2] chroot,head,shred,sort,split,tail: fix crash when
emitting --help
This crash only occurs when configured with both
--disable-bold-man-page-references and --disable-manual-url.
* src/system.h (oprintf_): Add a va_start and va_end call surrounding
the call to vprintf.
Copyright-paperwork-exempt: Yes
---
src/system.h | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/system.h b/src/system.h
index 926426204..84be742ff 100644
--- a/src/system.h
+++ b/src/system.h
@@ -727,7 +727,9 @@ oprintf_ (char const *program, char const *message, ...)
if (buflen < 0)
{
+ va_start (args, message);
vprintf (message, args);
+ va_end (args);
return;
}
--
2.56.0
>From 9c7cf20c3cbe0add2dd9839c83df8e6c8d59516e Mon Sep 17 00:00:00 2001
Message-ID: <9c7cf20c3cbe0add2dd9839c83df8e6c8d59516e.1791519677.git.collin.fu...@gmail.com>
In-Reply-To: <d66cf56e25e3fa7d120c0fab2ce793c51763effb.1791519677.git.collin.fu...@gmail.com>
References: <d66cf56e25e3fa7d120c0fab2ce793c51763effb.1791519677.git.collin.fu...@gmail.com>
From: Collin Funk <[email protected]>
Date: Thu, 8 Oct 2026 21:08:06 -0700
Subject: [PATCH 2/2] doc: NEWS: mention the fix from the previous commit
* NEWS: Mention the crash when invoking various programs --help option
when configured with --disable-bold-man-page-references and
--disable-manual-url.
---
NEWS | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/NEWS b/NEWS
index 246a12b41..2d7d9b3c9 100644
--- a/NEWS
+++ b/NEWS
@@ -37,6 +37,12 @@ GNU coreutils NEWS -*- outline -*-
into a seekable file whose size is a multiple of the page size.
[bug introduced in coreutils-8.24]
+ When configured with both --disable-bold-man-page-references and
+ --disable-manual-url, 'chroot', 'head', 'shred', 'sort', 'split', and 'tail'
+ no longer use an uninitialized va_list when printing --help. Previously, they
+ would likely crash due to this undefined behavior.
+ [bug introduced in coreutils-9.10]
+
** New Features
'env' and 'printenv' now support the --quoting-style option
--
2.56.0