* [PATCH] tools: xenalyze.c fix format-truncation
@ 2018-03-14 8:21 John Thomson
2018-03-14 10:07 ` George Dunlap
0 siblings, 1 reply; 2+ messages in thread
From: John Thomson @ 2018-03-14 8:21 UTC (permalink / raw)
To: xen-devel; +Cc: george.dunlap, John Thomson
With gcc optimization enabled by:
tools: detect appropriate debug optimization level
b43501451733193b265de30fd79a764363a2a473
-Wformat-truncation throws warnings
gcc version 7.3.0
xenalyze.c: In function 'find_symbol':
xenalyze.c:382:36: error: 'snprintf' output may be truncated before the last format character [-Werror=format-truncation=]
snprintf(name, 128, "(%s +%llx)",
^
xenalyze.c:382:5: note: 'snprintf' output between 6 and 144 bytes into a destination of size 128
snprintf(name, 128, "(%s +%llx)",
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
lastname, offset);
~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
Signed-off-by: John Thomson <git@johnthomson.fastmail.com.au>
---
tools/xentrace/xenalyze.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/xentrace/xenalyze.c b/tools/xentrace/xenalyze.c
index 5768b54f86..5ed0a12327 100644
--- a/tools/xentrace/xenalyze.c
+++ b/tools/xentrace/xenalyze.c
@@ -358,7 +358,7 @@ char * find_symbol(unsigned long long addr) {
int i;
char * lastname="ZERO";
unsigned long long offset=addr;
- static char name[128];
+ static char name[144];
if(!p) {
name[0]=0;
@@ -379,7 +379,7 @@ char * find_symbol(unsigned long long addr) {
p=p->next;
}
finish:
- snprintf(name, 128, "(%s +%llx)",
+ snprintf(name, 144, "(%s +%llx)",
lastname, offset);
return name;
}
--
2.16.2
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] tools: xenalyze.c fix format-truncation
2018-03-14 8:21 [PATCH] tools: xenalyze.c fix format-truncation John Thomson
@ 2018-03-14 10:07 ` George Dunlap
0 siblings, 0 replies; 2+ messages in thread
From: George Dunlap @ 2018-03-14 10:07 UTC (permalink / raw)
To: John Thomson, xen-devel; +Cc: george.dunlap
On 03/14/2018 08:21 AM, John Thomson wrote:
> With gcc optimization enabled by:
> tools: detect appropriate debug optimization level
> b43501451733193b265de30fd79a764363a2a473
>
> -Wformat-truncation throws warnings
>
> gcc version 7.3.0
>
> xenalyze.c: In function 'find_symbol':
> xenalyze.c:382:36: error: 'snprintf' output may be truncated before the last format character [-Werror=format-truncation=]
> snprintf(name, 128, "(%s +%llx)",
> ^
> xenalyze.c:382:5: note: 'snprintf' output between 6 and 144 bytes into a destination of size 128
> snprintf(name, 128, "(%s +%llx)",
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> lastname, offset);
> ~~~~~~~~~~~~~~~~~
> cc1: all warnings being treated as errors
>
> Signed-off-by: John Thomson <git@johnthomson.fastmail.com.au>
It probably really wants to include SYMBOL_NAME_SIZE somewhere, but
that's a minor clean-up for another day. :-)
Thanks!
Reviewed-by: George Dunlap <george.dunlap@citrix.com>
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-03-14 10:08 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-14 8:21 [PATCH] tools: xenalyze.c fix format-truncation John Thomson
2018-03-14 10:07 ` George Dunlap
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.