From: Dan Carpenter <dan.carpenter@oracle.com>
To: kernel-janitors@vger.kernel.org
Subject: [patch] x86/pkeys: seftests: off by one in sigsafe_printf()
Date: Thu, 13 Oct 2016 08:52:43 +0000 [thread overview]
Message-ID: <20161013085243.GF16198@mwanda> (raw)
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);
reply other threads:[~2016-10-13 8:52 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20161013085243.GF16198@mwanda \
--to=dan.carpenter@oracle.com \
--cc=kernel-janitors@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox