[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen master] tools: libxenstat: fix format string overflow



commit 8f9ccfe93570ecae18d9cc224931787d0bca9c66
Author:     Dario Faggioli <dfaggioli@xxxxxxxx>
AuthorDate: Fri Feb 16 19:38:48 2018 +0100
Commit:     Wei Liu <wei.liu2@xxxxxxxxxx>
CommitDate: Mon Feb 19 17:04:43 2018 +0000

    tools: libxenstat: fix format string overflow
    
    With gcc 7.3.0, the build fails like this:
    
    src/xenstat_linux.c: In function â??getBridgeâ??
    src/xenstat_linux.c:78:34: warning: â??%sâ?? directive writing up to 255 
bytes into a region of size 241 [-Wformat-overflow=]
         sprintf(tmp, "/sys/class/net/%s/bridge", de->d_name);
                                      ^~
    src/xenstat_linux.c:78:5: note: â??sprintfâ?? output between 23 and 278 
bytes into a destination of size 256
         sprintf(tmp, "/sys/class/net/%s/bridge", de->d_name);
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    Fix by making the buffer bigger.
    
    Signed-off-by: Dario Faggioli <dfaggioli@xxxxxxxx>
    Acked-by: Wei Liu <wei.liu2@xxxxxxxxxx>
---
 tools/xenstat/libxenstat/src/xenstat_linux.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/xenstat/libxenstat/src/xenstat_linux.c 
b/tools/xenstat/libxenstat/src/xenstat_linux.c
index 907d65f..7cdd3bf 100644
--- a/tools/xenstat/libxenstat/src/xenstat_linux.c
+++ b/tools/xenstat/libxenstat/src/xenstat_linux.c
@@ -69,7 +69,7 @@ void getBridge(char *excludeName, char *result, size_t 
resultLen)
        struct dirent *de;
        DIR *d;
 
-       char tmp[256] = { 0 };
+       char tmp[512] = { 0 };
 
        d = opendir("/sys/class/net");
        while ((de = readdir(d)) != NULL) {
--
generated by git-patchbot for /home/xen/git/xen.git#master

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/xen-changelog

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.