[PATCH 1/2] tools/nolibc: fix verrx() and errx() message formatting
From: Danish Khateeb
Date: Thu Sep 24 2026 - 08:22:48 EST
verrx() passes its va_list to warnx() instead of vwarnx(). warnx() is
variadic, so it takes the va_list as its first and only argument, and
the conversions in the format string print the va_list itself and then
whatever is left in the following argument slots. On x86_64, for
instance,
errx(1, "int args: %d %d %d", 1, 2, 3);
prints something like "int args: -1699009032 1 2", where the first
number comes from the address of the va_list and changes from run to
run, and
errx(1, "%d %s", 1234, "foo");
crashes with SIGSEGV, as "%s" takes a leftover argument slot for the
string. errx() goes through verrx(), so every message with arguments
printed by either of them is wrong.
Call vwarnx(), as verr() calls vwarn().
Fixes: 9da0f529c089 ("tools/nolibc: add err.h")
Assisted-by: LLM
Signed-off-by: Danish Khateeb <danishkhateeb03@xxxxxxxxx>
---
tools/include/nolibc/err.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/include/nolibc/err.h b/tools/include/nolibc/err.h
index e22ae87a7289..61978d537ed8 100644
--- a/tools/include/nolibc/err.h
+++ b/tools/include/nolibc/err.h
@@ -60,7 +60,7 @@ void verr(int eval, const char *fmt, va_list args)
static __attribute__((noreturn, unused))
void verrx(int eval, const char *fmt, va_list args)
{
- warnx(fmt, args);
+ vwarnx(fmt, args);
exit(eval);
}
--
2.55.0