Skip to content

Commit

Permalink
backtrace: fix off-by-one on string output
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Alexander Motin <[email protected]>
Signed-off-by: Rob Norris <[email protected]>
Closes #16862
robn authored Dec 13, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 6c9b4f1 commit ecc0970
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/libspl/backtrace.c
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit ecc0970

Please sign in to comment.