libxl: fix bootloader args setting [with diff]
PATCH 1/1 libxl: fix bootloader args setting [with diff]
# HG changeset patch
# User Zhigang Wang <[email protected]> # Date 1328541193 18000
# Node ID 72f1296a55a470426e1c3e5b8b2ba907ab6eb78c # Parent 3432abcf9380d3840ca38439a304f74a37d155fc
libxl: fix bootloader args setting
When bootloader_args = ['foo', 'bar'], then info->u.pv.bootloader_args =
foo\0
bar\0
\0Before this patch, 'p++' points to the next character of 'foo\0' and never comes to 'bar\0' (because of the '\0' in 'foo\0'), so the args will be:
args[0] = 'oo\0'
args[1] = 'o\0'After this patch, 'p++' points to the next string of pv.bootloader_args, so we get the correct args:
args[0] = 'foo\0'
args[1] = 'bar\0'tools/libxl/libxl_bootloader.c +5 -3
@@ -49,9 +49,11 @@ static char **make_bootloader_args(libxlflexarray_set (args, nr++,libxl__sprintf (gc,"--output-directory=%s" ,"/var/run/libxl/" ));if (info->u.pv.bootloader_args) { -char *p = info->u.pv.bootloader_args[0 ]; -while (*(p++)) -flexarray_set (args, nr++, p); +char **p = info->u.pv.bootloader_args; +while (*p) { +flexarray_set (args, nr++, *p); + p++; + } }flexarray_set (args, nr++, disk);
Quoted 19 lines · Zhigang Wang
# HG changeset patch
# User Zhigang Wang <[email protected]> # Date 1328541193 18000
# Node ID72f1296a55a470426e1c3e5b8b2ba907ab6eb78c# Parent3432abcf9380d3840ca38439a304f74a37d155fc
libxl: fix bootloader args settingWhen
bootloader_args= ['foo', 'bar'], theninfo->u.pv.bootloader_args=foo\0 bar\0 \0Before this patch, 'p++' points to the next character of 'foo\0' and never comes to 'bar\0' (because of the '\0' in 'foo\0'), so the args will be:
args[0] = 'oo\0' args[1] = 'o\0'
Quoted 7 lines
After this patch, 'p++' points to the next string of pv.bootloader_args, so we get the correct args:
args[0] = 'foo\0' args[1] = 'bar\0'Signed-off-by Zhigang Wang <[email protected]>
Quoted 23 lines
diff -r
3432abcf9380-r72f1296a55a4tools/libxl/libxl_bootloader.ctools/libxl/libxl_bootloader.c +5
-3@@ -49,9 +49,11 @@ static char **make_bootloader_args(libxlflexarray_set (args, nr++,libxl__sprintf (gc,"--output-directory=%s" ,"/var/run/libxl/" ));if (info->u.pv.bootloader_args) { -char *p = info->u.pv.bootloader_args[0 ]; -while (*(p++)) -flexarray_set (args, nr++, p); +char **p = info->u.pv.bootloader_args; +while (*p) { +flexarray_set (args, nr++, *p); + p++; + } }flexarray_set (args, nr++, disk);_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel