From: Tim Deegan <tim@xen.org>
To: xen-devel@lists.xen.org
Subject: [PATCH 1/4] common/vsprintf: Explicitly treat negative lengths as 'unlimited'
Date: Thu, 28 Nov 2013 16:37:42 +0000 [thread overview]
Message-ID: <1385656665-12551-2-git-send-email-tim@xen.org> (raw)
In-Reply-To: <1385656665-12551-1-git-send-email-tim@xen.org>
The old code relied on implictly casting negative numbers to size_t
making a very large limit, which was correct but non-obvious.
Coverity CID 1128575
Signed-off-by: Tim Deegan <tim@xen.org>
---
xen/common/vsprintf.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/xen/common/vsprintf.c b/xen/common/vsprintf.c
index 43dc392..68553bb 100644
--- a/xen/common/vsprintf.c
+++ b/xen/common/vsprintf.c
@@ -239,7 +239,7 @@ static char *number(
static char *string(char *str, char *end, const char *s,
int field_width, int precision, int flags)
{
- int i, len = strnlen(s, precision);
+ int i, len = (precision < 0) ? strlen(s) : strnlen(s, precision);
if (!(flags & LEFT)) {
while (len < field_width--) {
--
1.8.4.rc3
next prev parent reply other threads:[~2013-11-28 16:37 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-28 16:37 [PATCH 0/4] xen: more Coverity-inspired tidying Tim Deegan
2013-11-28 16:37 ` Tim Deegan [this message]
2013-11-28 16:48 ` [PATCH 1/4] common/vsprintf: Explicitly treat negative lengths as 'unlimited' Andrew Cooper
2013-11-29 10:45 ` Ian Campbell
2013-11-28 16:37 ` [PATCH 2/4] x86/shadow: Drop shadow_mode_trap_reads() Tim Deegan
2013-11-28 16:37 ` [PATCH 3/4] x86/mem_sharing: drop unused variable Tim Deegan
2013-11-28 16:50 ` Andrew Cooper
2013-11-28 16:37 ` [PATCH 4/4] bitmaps/bitops: Clarify tests for small constant size Tim Deegan
2013-11-29 10:07 ` Jan Beulich
2013-11-29 10:37 ` Tim Deegan
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=1385656665-12551-2-git-send-email-tim@xen.org \
--to=tim@xen.org \
--cc=xen-devel@lists.xen.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;
as well as URLs for NNTP newsgroup(s).