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 <behlendorf1@llnl.gov>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Signed-off-by: Rob Norris <robn@despairlabs.com>
Closes #16862
This commit is contained in:
Rob Norris 2024-12-14 05:12:14 +11:00 committed by GitHub
parent 6c9b4f18d3
commit ecc0970e3e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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