xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Zhigang Wang <zhigang.x.wang@oracle.com>
To: xen-devel@lists.xenproject.org
Cc: Wei Liu <wei.liu2@citrix.com>,
	Ian Campbell <ian.campbell@citrix.com>,
	Stefano Stabellini <stefano.stabellini@eu.citrix.com>,
	Ian Jackson <ian.jackson@eu.citrix.com>,
	Zhigang Wang <zhigang.x.wang@oracle.com>
Subject: [PATCH] tools/xenstat: handle network interface name in uppercase.
Date: Wed, 20 Apr 2016 10:16:35 -0400	[thread overview]
Message-ID: <1461161795-28948-1-git-send-email-zhigang.x.wang@oracle.com> (raw)
In-Reply-To: <20160420113910.GA4311@citrix.com>

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>
---
 tools/xenstat/libxenstat/src/xenstat_linux.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/tools/xenstat/libxenstat/src/xenstat_linux.c b/tools/xenstat/libxenstat/src/xenstat_linux.c
index 2cc9c7f..907d65f 100644
--- a/tools/xenstat/libxenstat/src/xenstat_linux.c
+++ b/tools/xenstat/libxenstat/src/xenstat_linux.c
@@ -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);
 			}
-- 
2.5.5


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

  reply	other threads:[~2016-04-20 14:17 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-11 20:18 [PATCH] tools/xenstat: handle network interface name in uppercase Zhigang Wang
2016-04-19 21:03 ` Zhigang Wang
2016-04-20 11:39 ` Wei Liu
2016-04-20 14:16   ` Zhigang Wang [this message]
2016-04-20 15:12     ` Wei Liu
2016-04-20 18:07       ` 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=1461161795-28948-1-git-send-email-zhigang.x.wang@oracle.com \
    --to=zhigang.x.wang@oracle.com \
    --cc=ian.campbell@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xenproject.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).