From 6604fe9a069e7fd7a6aa28110ee47d6afd5befc4 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Sat, 14 Dec 2024 05:12:14 +1100 Subject: [PATCH] backtrace: fix off-by-one on string output sizeof("foo") includes the trailing null byte, so all the output had nulls through it. Most terminals quietly ignore it, but it makes some tools misdetect file types and other annoyances. Easy fix: subtract 1. Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf Reviewed-by: Alexander Motin Signed-off-by: Rob Norris Closes #16862 --- lib/libspl/backtrace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/libspl/backtrace.c b/lib/libspl/backtrace.c index 6e8b3b121..7f1ef596f 100644 --- a/lib/libspl/backtrace.c +++ b/lib/libspl/backtrace.c @@ -38,7 +38,7 @@ */ #define spl_bt_write_n(fd, s, n) \ do { ssize_t r __maybe_unused = write(fd, s, n); } while (0) -#define spl_bt_write(fd, s) spl_bt_write_n(fd, s, sizeof (s)) +#define spl_bt_write(fd, s) spl_bt_write_n(fd, s, sizeof (s)-1) #if defined(HAVE_LIBUNWIND) #define UNW_LOCAL_ONLY