* [patch] x86/pkeys: seftests: off by one in sigsafe_printf()
@ 2016-10-13 8:52 Dan Carpenter
0 siblings, 0 replies; only message in thread
From: Dan Carpenter @ 2016-10-13 8:52 UTC (permalink / raw)
To: kernel-janitors
We want "len" to represent the number of characters printed not counting
the NUL terminator. At most there will be "DPRINT_IN_SIGNAL_BUF_SIZE - 1"
characters printed.
Fixes: 5f23f6d082a9 ("x86/pkeys: Add self-tests")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
diff --git a/tools/testing/selftests/x86/pkey-helpers.h b/tools/testing/selftests/x86/pkey-helpers.h
index b202939..1f21661 100644
--- a/tools/testing/selftests/x86/pkey-helpers.h
+++ b/tools/testing/selftests/x86/pkey-helpers.h
@@ -36,8 +36,8 @@ static inline void sigsafe_printf(const char *format, ...)
* len is amount that would have been printed,
* but actual write is truncated at BUF_SIZE.
*/
- if (len > DPRINT_IN_SIGNAL_BUF_SIZE)
- len = DPRINT_IN_SIGNAL_BUF_SIZE;
+ if (len >= DPRINT_IN_SIGNAL_BUF_SIZE)
+ len = DPRINT_IN_SIGNAL_BUF_SIZE - 1;
write(1, dprint_in_signal_buffer, len);
}
va_end(ap);
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2016-10-13 8:52 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-13 8:52 [patch] x86/pkeys: seftests: off by one in sigsafe_printf() Dan Carpenter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox