File xen.f49fa658b53580cf2ad354d2bf1796766cc11222.patch of Package xen
From: Seraphime Kirkovski <kirkseraph@gmail.com>
Date: Tue, 4 Apr 2017 19:31:59 +0200
Subject: f49fa658b53580cf2ad354d2bf1796766cc11222
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
tools:misc:xenlockprof: fix possible format string overflow
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>
Acked-by: Wei Liu <wei.liu2@citrix.com>
---
tools/misc/xenlockprof.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/tools/misc/xenlockprof.c
+++ b/tools/misc/xenlockprof.c
@@ -15,25 +15,25 @@
#include <stdlib.h>
#include <sys/mman.h>
#include <errno.h>
#include <string.h>
#include <inttypes.h>
int main(int argc, char *argv[])
{
xc_interface *xc_handle;
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)) )
{
printf("%s: [-r]\n", argv[0]);
printf("no args: print lock profile data\n");
printf(" -r : reset profile data\n");
return 1;
}
if ( (xc_handle = xc_interface_open(0,0,0)) == 0 )
{