xl: use xstrdup in cpurange_parse
PATCH 1/1 xl: use xstrdup in cpurange_parse
This ensures buf is always valid when it is passed to strtok_r.
CID: 1291936
---
Cc: Ian Jackson <[email protected]>
This is a backport candidate.
--- tools/libxl/xl_cmdimpl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/libxl/xl_cmdimpl.c +1 -1
@@ -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;
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
Quoted 7 lines · Wei Liu
This ensures buf is always valid when it is passed to
strtok_r.CID: 1291936
Signed-off-by Wei Liu <[email protected]>---
Cc: Ian Jackson <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Wei Liu writes ("[PATCH for-4.7] xl: use xstrdup in cpurange_parse"):
Quoted 5 lines
This ensures buf is always valid when it is passed to
strtok_r.CID: 1291936
Signed-off-by Wei Liu <[email protected]>
Quoted 1 line
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
[email protected]
http://lists.xen.org/xen-devel
Quoted 5 lines · Ian Jackson
Wei Liu writes ("[PATCH for-4.7] xl: use xstrdup in
cpurange_parse"):Quoted 4 lines
This ensures buf is always valid when it is passed to
strtok_r.CID: 1291936
Quoted 9 lines
Quoted 1 line
Signed-off-by Wei Liu <[email protected]>Acked-by Ian Jackson <[email protected]>Quoted 1 line
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. :-)
Quoted 1 line
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 5 lines · Wei Liu
This ensures buf is always valid when it is passed to
strtok_r.CID: 1291936
Signed-off-by Wei Liu <[email protected]>
Pushed. Thanks everyone.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel