]> xenbits.xensource.com Git - people/royger/xen.git/commitdiff
tools/xenstat: handle network interface name in uppercase.
authorZhigang Wang <zhigang.x.wang@oracle.com>
Wed, 20 Apr 2016 14:16:35 +0000 (10:16 -0400)
committerWei Liu <wei.liu2@citrix.com>
Wed, 20 Apr 2016 18:01:33 +0000 (19:01 +0100)
xentop will segmentation fault in this case:

  # ip link set eth1 down
  # ip link set eth1 name ETH
  # xentop

This patch will let xentop to handle all uppercase network interface name.

Signed-off-by: Zhigang Wang <zhigang.x.wang@oracle.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
Release-acked-by: Wei Liu <wei.liu2@citrix.com>
tools/xenstat/libxenstat/src/xenstat_linux.c

index 2cc9c7f0008e554045410cb707cd9a958e228745..907d65fa6386a06f2824067125ec897953798168 100644 (file)
@@ -219,8 +219,11 @@ int parseNetDevLine(char *line, char *iface, unsigned long long *rxBytes, unsign
                                }
                                else
                                /* There were errors when parsing this directly in RE. strpbrk() helps */
-                               if (iface != NULL)
-                                       strcpy(iface, strpbrk(tmp, "abcdefghijklmnopqrstvuwxyz0123456789"));
+                               if (iface != NULL) {
+                                       char *tmp2 = strpbrk(tmp, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789");
+                                       if (tmp2 != NULL)
+                                               strcpy(iface, tmp2);
+                               }
 
                                memset(tmp, 0, matches[i].rm_eo - matches[i].rm_so);
                        }