]> xenbits.xensource.com Git - xen.git/commitdiff
libxl: fix libxl_string_list_length and its only caller
authorMatthew Daley <mattjd@gmail.com>
Wed, 18 Sep 2013 03:37:40 +0000 (15:37 +1200)
committerIan Campbell <ian.campbell@citrix.com>
Wed, 25 Sep 2013 11:42:02 +0000 (12:42 +0100)
The wrong amount of indirections were being taken in
libxl_string_list_length, and its only caller was miscounting the amount
of initial non-list arguments, seemingly since the initial commit
(599c784).

This has been seen and reported in the wild (##xen):
< Trixboxer> Hi, any idea why would I get
< Trixboxer> xl: libxl_bootloader.c:42: bootloader_arg: Assertion `bl->nargs < bl->argsspace' failed.
< Trixboxer> 4.2.2-23.el6

Coverity-ID: 1054954
Signed-off-by: Matthew Daley <mattjd@gmail.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
tools/libxl/libxl.c
tools/libxl/libxl_bootloader.c

index 0879f2331f39cb2dcdbf5a63686c08db87e69572..ca24ca37cd4a1d242da106bf935f82c1860e7424 100644 (file)
@@ -202,7 +202,7 @@ int libxl_string_list_length(const libxl_string_list *psl)
 {
     if (!psl) return 0;
     int i = 0;
-    while (*psl++) i++;
+    while ((*psl)[i]) i++;
     return i;
 }
 
index ed12b2cf2b83c5fa8d49653d9dc312a83e365241..3287bf77da9a64327736e6bf923608e0c2bb3a52 100644 (file)
@@ -48,7 +48,7 @@ static void make_bootloader_args(libxl__gc *gc, libxl__bootloader_state *bl,
 {
     const libxl_domain_build_info *info = bl->info;
 
-    bl->argsspace = 7 + libxl_string_list_length(&info->u.pv.bootloader_args);
+    bl->argsspace = 9 + libxl_string_list_length(&info->u.pv.bootloader_args);
 
     GCNEW_ARRAY(bl->args, bl->argsspace);