]> xenbits.xensource.com Git - xen.git/commitdiff
xl: correctly handle null extra config in main_config_update
authorWei Liu <wei.liu2@citrix.com>
Tue, 14 Jul 2015 16:41:11 +0000 (17:41 +0100)
committerIan Campbell <ian.campbell@citrix.com>
Wed, 15 Jul 2015 09:58:08 +0000 (10:58 +0100)
Don't dereference NULL.

Also fixed a typo in error string while I was there.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
tools/libxl/xl_cmdimpl.c

index 607db4e998c16444171df5e95ee0f3b34fa22bf3..888f729fe4aca3f9a5829f39d8f115b630d9297f 100644 (file)
@@ -5010,9 +5010,9 @@ int main_config_update(int argc, char **argv)
         if (rc) { fprintf(stderr, "Failed to read config file: %s: %s\n",
                            filename, strerror(errno));
                   free(extra_config); return ERROR_FAIL; }
-        if (strlen(extra_config)) {
+        if (extra_config && strlen(extra_config)) {
             if (config_len > INT_MAX - (strlen(extra_config) + 2 + 1)) {
-                fprintf(stderr, "Failed to attach extra configration\n");
+                fprintf(stderr, "Failed to attach extra configuration\n");
                 exit(1);
             }
             /* allocate space for the extra config plus two EOLs plus \0 */