xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Seraphime Kirkovski <kirkseraph@gmail.com>
To: xen-devel@lists.xen.org
Cc: Ian Jackson <ian.jackson@eu.citrix.com>,
	Wei Liu <wei.liu2@citrix.com>,
	Seraphime Kirkovski <kirkseraph@gmail.com>
Subject: [PATCH] tools:misc:xenlockprof: fix possible format string overflow
Date: Tue,  4 Apr 2017 19:31:59 +0200	[thread overview]
Message-ID: <20170404173159.29762-1-kirkseraph@gmail.com> (raw)

GCC7 complains about a possible overflow/truncation in xenlockprof.

xenlockprof.c: In function ‘main’:
xenlockprof.c:100:53: error: ‘%s’ directive writing up to 39 bytes into a
                         region of size between 17 and 37 [-Werror=format-overflow=]
             sprintf(name, "unknown type(%d) %d lock %s", data[j].type,
                                                     ^~
xenlockprof.c:100:13: note: ‘sprintf’ output between 24 and 83 bytes
                                             into a destination of size 60
             sprintf(name, "unknown type(%d) %d lock %s", data[j].type,
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                     data[j].idx, data[j].name);
                     ~~~~~~~~~~~~~~~~~~~~~~~~~~

This increases the size of name to 100. Not the most scalable solution,
but certainly the "cheapest", as it doesn't add dependencies for
asprintf.

Signed-off-by: Seraphime Kirkovski <kirkseraph@gmail.com>
---
 tools/misc/xenlockprof.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/misc/xenlockprof.c b/tools/misc/xenlockprof.c
index 41fcb792cc..df23c82912 100644
--- a/tools/misc/xenlockprof.c
+++ b/tools/misc/xenlockprof.c
@@ -24,7 +24,7 @@ int main(int argc, char *argv[])
     uint32_t           i, j, n;
     uint64_t           time;
     double             l, b, sl, sb;
-    char               name[60];
+    char               name[100];
     DECLARE_HYPERCALL_BUFFER(xc_lockprof_data_t, data);
 
     if ( (argc > 2) || ((argc == 2) && (strcmp(argv[1], "-r") != 0)) )
-- 
2.11.0


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

             reply	other threads:[~2017-04-04 17:31 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-04 17:31 Seraphime Kirkovski [this message]
2017-04-05 11:21 ` [PATCH] tools:misc:xenlockprof: fix possible format string overflow Wei Liu

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=20170404173159.29762-1-kirkseraph@gmail.com \
    --to=kirkseraph@gmail.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=wei.liu2@citrix.com \
    --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).