xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH for-4.7] xl: use xstrdup in cpurange_parse
@ 2016-05-25 13:23 Wei Liu
  2016-05-25 13:32 ` Andrew Cooper
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Wei Liu @ 2016-05-25 13:23 UTC (permalink / raw)
  To: Xen-devel; +Cc: Ian Jackson, Wei Liu

This ensures buf is always valid when it is passed to strtok_r.

CID: 1291936

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
---
Cc: Ian Jackson <ian.jackson@eu.citrix.com>

This is a backport candidate.
---
 tools/libxl/xl_cmdimpl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
index 03ab644..d8530f0 100644
--- a/tools/libxl/xl_cmdimpl.c
+++ b/tools/libxl/xl_cmdimpl.c
@@ -847,7 +847,7 @@ static int update_cpumap_range(const char *str, libxl_bitmap *cpumap)
  */
 static int cpurange_parse(const char *cpu, libxl_bitmap *cpumap)
 {
-    char *ptr, *saveptr = NULL, *buf = strdup(cpu);
+    char *ptr, *saveptr = NULL, *buf = xstrdup(cpu);
     int rc = 0;
 
     for (ptr = strtok_r(buf, ",", &saveptr); ptr;
-- 
2.1.4


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

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

* Re: [PATCH for-4.7] xl: use xstrdup in cpurange_parse
  2016-05-25 13:23 [PATCH for-4.7] xl: use xstrdup in cpurange_parse Wei Liu
@ 2016-05-25 13:32 ` Andrew Cooper
  2016-05-25 13:33 ` Ian Jackson
  2016-05-25 13:44 ` Wei Liu
  2 siblings, 0 replies; 5+ messages in thread
From: Andrew Cooper @ 2016-05-25 13:32 UTC (permalink / raw)
  To: Wei Liu, Xen-devel; +Cc: Ian Jackson

On 25/05/16 14:23, Wei Liu wrote:
> This ensures buf is always valid when it is passed to strtok_r.
>
> CID: 1291936
>
> Signed-off-by: Wei Liu <wei.liu2@citrix.com>
> ---
> Cc: Ian Jackson <ian.jackson@eu.citrix.com>

Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>

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

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

* Re: [PATCH for-4.7] xl: use xstrdup in cpurange_parse
  2016-05-25 13:23 [PATCH for-4.7] xl: use xstrdup in cpurange_parse Wei Liu
  2016-05-25 13:32 ` Andrew Cooper
@ 2016-05-25 13:33 ` Ian Jackson
  2016-05-25 13:36   ` Wei Liu
  2016-05-25 13:44 ` Wei Liu
  2 siblings, 1 reply; 5+ messages in thread
From: Ian Jackson @ 2016-05-25 13:33 UTC (permalink / raw)
  To: Wei Liu; +Cc: Xen-devel

Wei Liu writes ("[PATCH for-4.7] xl: use xstrdup in cpurange_parse"):
> This ensures buf is always valid when it is passed to strtok_r.
> 
> CID: 1291936
> 
> Signed-off-by: Wei Liu <wei.liu2@citrix.com>

Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>

> This is a backport candidate.

Really ?  malloc failing is vanishingly rare in practice nowadays and
the consequence is a crash (which is what xstrdup achieves anyway).

Ian.

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

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

* Re: [PATCH for-4.7] xl: use xstrdup in cpurange_parse
  2016-05-25 13:33 ` Ian Jackson
@ 2016-05-25 13:36   ` Wei Liu
  0 siblings, 0 replies; 5+ messages in thread
From: Wei Liu @ 2016-05-25 13:36 UTC (permalink / raw)
  To: Ian Jackson; +Cc: Xen-devel, Wei Liu

On Wed, May 25, 2016 at 02:33:41PM +0100, Ian Jackson wrote:
> Wei Liu writes ("[PATCH for-4.7] xl: use xstrdup in cpurange_parse"):
> > This ensures buf is always valid when it is passed to strtok_r.
> > 
> > CID: 1291936
> > 
> > Signed-off-by: Wei Liu <wei.liu2@citrix.com>
> 
> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
> 
> > This is a backport candidate.
> 
> Really ?  malloc failing is vanishingly rare in practice nowadays and
> the consequence is a crash (which is what xstrdup achieves anyway).
> 

This is a fair argument. I will leave the judgement to you. If you don't
think this is worth backporting I won't insist. :-)

> Ian.

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

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

* Re: [PATCH for-4.7] xl: use xstrdup in cpurange_parse
  2016-05-25 13:23 [PATCH for-4.7] xl: use xstrdup in cpurange_parse Wei Liu
  2016-05-25 13:32 ` Andrew Cooper
  2016-05-25 13:33 ` Ian Jackson
@ 2016-05-25 13:44 ` Wei Liu
  2 siblings, 0 replies; 5+ messages in thread
From: Wei Liu @ 2016-05-25 13:44 UTC (permalink / raw)
  To: Xen-devel; +Cc: Ian Jackson, Wei Liu

On Wed, May 25, 2016 at 02:23:56PM +0100, Wei Liu wrote:
> This ensures buf is always valid when it is passed to strtok_r.
> 
> CID: 1291936
> 
> Signed-off-by: Wei Liu <wei.liu2@citrix.com>

Pushed. Thanks everyone.

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

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

end of thread, other threads:[~2016-05-25 13:44 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-25 13:23 [PATCH for-4.7] xl: use xstrdup in cpurange_parse Wei Liu
2016-05-25 13:32 ` Andrew Cooper
2016-05-25 13:33 ` Ian Jackson
2016-05-25 13:36   ` Wei Liu
2016-05-25 13:44 ` 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).