On Sun, Jun 11, 2017 at 11:10:30AM -0600, Theo de Raadt wrote: > + write(STDERR_FILENO, NO_KTRACE, sizeof(NO_KTRACE)); > > Naw, I dislike that sizeof. > > You can use dprintf, it is signal-safe in OpenBSD as long as the format > string doesn't contain floating-point strings.
Attaching updated diff.
? ktrace ? ktrace.1.diff ? ktrace.diff Index: ktrace.c =================================================================== RCS file: /cvs/src/usr.bin/ktrace/ktrace.c,v retrieving revision 1.33 diff -u -p -r1.33 ktrace.c --- ktrace.c 18 Jul 2016 09:36:50 -0000 1.33 +++ ktrace.c 11 Jun 2017 17:17:59 -0000 @@ -250,10 +250,7 @@ usage(void) static void no_ktrace(int signo) { - char buf[8192]; - - snprintf(buf, sizeof(buf), + dprintf(STDERR_FILENO, "error:\tktrace() system call not supported in the running kernel\n\tre-compile kernel with 'option KTRACE'\n"); - write(STDERR_FILENO, buf, strlen(buf)); _exit(1); }