xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] tools/xenstat: handle network interface name in uppercase.
@ 2016-03-11 20:18 Zhigang Wang
  2016-04-19 21:03 ` Zhigang Wang
  2016-04-20 11:39 ` Wei Liu
  0 siblings, 2 replies; 6+ messages in thread
From: Zhigang Wang @ 2016-03-11 20:18 UTC (permalink / raw)
  To: xen-devel; +Cc: Zhigang Wang, Ian Jackson, Ian Campbell, Stefano Stabellini

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 | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/tools/xenstat/libxenstat/src/xenstat_linux.c b/tools/xenstat/libxenstat/src/xenstat_linux.c
index 931b24e..d33eca1 100644
--- a/tools/xenstat/libxenstat/src/xenstat_linux.c
+++ b/tools/xenstat/libxenstat/src/xenstat_linux.c
@@ -101,6 +101,7 @@ int parseNetDevLine(char *line, char *iface, unsigned long long *rxBytes, unsign
 	/* Temporary/helper variables */
 	int ret;
 	char *tmp;
+	char *tmp2;
 	int i = 0, x = 0, col = 0;
 	regex_t r;
 	regmatch_t matches[19];
@@ -221,8 +222,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) {
+					tmp2 = strpbrk(tmp, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789");
+					if (tmp2 != NULL)
+						strcpy(iface, tmp2);
+				}
 
 				memset(tmp, 0, matches[i].rm_eo - matches[i].rm_so);
 			}
-- 
2.5.0


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

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] tools/xenstat: handle network interface name in uppercase.
  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
  1 sibling, 0 replies; 6+ messages in thread
From: Zhigang Wang @ 2016-04-19 21:03 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson, Ian Campbell, Stefano Stabellini

Could anyone have a look at this patch?

Thanks,

Zhigang

On 03/11/2016 03:18 PM, Zhigang Wang wrote:
> 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 | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/xenstat/libxenstat/src/xenstat_linux.c b/tools/xenstat/libxenstat/src/xenstat_linux.c
> index 931b24e..d33eca1 100644
> --- a/tools/xenstat/libxenstat/src/xenstat_linux.c
> +++ b/tools/xenstat/libxenstat/src/xenstat_linux.c
> @@ -101,6 +101,7 @@ int parseNetDevLine(char *line, char *iface, unsigned long long *rxBytes, unsign
>  	/* Temporary/helper variables */
>  	int ret;
>  	char *tmp;
> +	char *tmp2;
>  	int i = 0, x = 0, col = 0;
>  	regex_t r;
>  	regmatch_t matches[19];
> @@ -221,8 +222,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) {
> +					tmp2 = strpbrk(tmp, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789");
> +					if (tmp2 != NULL)
> +						strcpy(iface, tmp2);
> +				}
>  
>  				memset(tmp, 0, matches[i].rm_eo - matches[i].rm_so);
>  			}
> 


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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] tools/xenstat: handle network interface name in uppercase.
  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
  1 sibling, 1 reply; 6+ messages in thread
From: Wei Liu @ 2016-04-20 11:39 UTC (permalink / raw)
  To: Zhigang Wang
  Cc: xen-devel, Wei Liu, Ian Jackson, Ian Campbell, Stefano Stabellini

I wasn't CC'ed so this fled my attention.

On Fri, Mar 11, 2016 at 03:18:01PM -0500, Zhigang Wang wrote:
> 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 | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/xenstat/libxenstat/src/xenstat_linux.c b/tools/xenstat/libxenstat/src/xenstat_linux.c
> index 931b24e..d33eca1 100644
> --- a/tools/xenstat/libxenstat/src/xenstat_linux.c
> +++ b/tools/xenstat/libxenstat/src/xenstat_linux.c
> @@ -101,6 +101,7 @@ int parseNetDevLine(char *line, char *iface, unsigned long long *rxBytes, unsign
>  	/* Temporary/helper variables */
>  	int ret;
>  	char *tmp;
> +	char *tmp2;
>  	int i = 0, x = 0, col = 0;
>  	regex_t r;
>  	regmatch_t matches[19];
> @@ -221,8 +222,11 @@ int parseNetDevLine(char *line, char *iface, unsigned long long *rxBytes, unsign
>  				}
>  				else
>  				/* There were errors when parsing this directly in RE. strpbrk() helps */

This line indicates the most proper fix is to fix the regexp used to
also parse netdev name IMHO. That being said, there is no reason to
block a valid fix.

> -				if (iface != NULL)
> -					strcpy(iface, strpbrk(tmp, "abcdefghijklmnopqrstvuwxyz0123456789"));
> +				if (iface != NULL) {
> +					tmp2 = strpbrk(tmp, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789");
> +					if (tmp2 != NULL)
> +						strcpy(iface, tmp2);
> +				}

Please limit the scope of tmp2, if you only need that here, declare it
within this narrow scope please.


Wei.

>  
>  				memset(tmp, 0, matches[i].rm_eo - matches[i].rm_so);
>  			}
> -- 
> 2.5.0
> 
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> http://lists.xen.org/xen-devel

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] tools/xenstat: handle network interface name in uppercase.
  2016-04-20 11:39 ` Wei Liu
@ 2016-04-20 14:16   ` Zhigang Wang
  2016-04-20 15:12     ` Wei Liu
  0 siblings, 1 reply; 6+ messages in thread
From: Zhigang Wang @ 2016-04-20 14:16 UTC (permalink / raw)
  To: xen-devel
  Cc: Wei Liu, Ian Campbell, Stefano Stabellini, Ian Jackson, Zhigang Wang

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

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] tools/xenstat: handle network interface name in uppercase.
  2016-04-20 14:16   ` Zhigang Wang
@ 2016-04-20 15:12     ` Wei Liu
  2016-04-20 18:07       ` Wei Liu
  0 siblings, 1 reply; 6+ messages in thread
From: Wei Liu @ 2016-04-20 15:12 UTC (permalink / raw)
  To: Zhigang Wang
  Cc: Wei Liu, Ian Campbell, Stefano Stabellini, Ian Jackson, xen-devel

On Wed, Apr 20, 2016 at 10:16:35AM -0400, Zhigang Wang wrote:
> 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>

This fixes a real problem and is not possible to block the pushgate, so:

Release-acked-by: Wei Liu <wei.liu2@citrix.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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] tools/xenstat: handle network interface name in uppercase.
  2016-04-20 15:12     ` Wei Liu
@ 2016-04-20 18:07       ` Wei Liu
  0 siblings, 0 replies; 6+ messages in thread
From: Wei Liu @ 2016-04-20 18:07 UTC (permalink / raw)
  To: Zhigang Wang
  Cc: Wei Liu, Ian Campbell, Stefano Stabellini, Ian Jackson, xen-devel

On Wed, Apr 20, 2016 at 04:12:59PM +0100, Wei Liu wrote:
> On Wed, Apr 20, 2016 at 10:16:35AM -0400, Zhigang Wang wrote:
> > 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>
> 
> This fixes a real problem and is not possible to block the pushgate, so:
> 
> Release-acked-by: Wei Liu <wei.liu2@citrix.com>
> 

Applied.

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-04-20 18:06 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2016-04-20 15:12     ` Wei Liu
2016-04-20 18:07       ` Wei Liu

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).