]> Git Repo - qemu.git/commitdiff
block/qapi: fix unbounded stack for dump_qdict
authorPeter Xu <[email protected]>
Wed, 9 Mar 2016 05:56:37 +0000 (13:56 +0800)
committerKevin Wolf <[email protected]>
Wed, 30 Mar 2016 09:59:32 +0000 (11:59 +0200)
Using heap instead of stack for better safety.

Signed-off-by: Peter Xu <[email protected]>
Reviewed-by: Eric Blake <[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
block/qapi.c

index e0e6e96ad2ad0e9c30124219c4302352b9640b9a..1961cdf707685e39c127229b1ef5266ea465421f 100644 (file)
@@ -669,7 +669,7 @@ static void dump_qdict(fprintf_function func_fprintf, void *f, int indentation,
     for (entry = qdict_first(dict); entry; entry = qdict_next(dict, entry)) {
         QType type = qobject_type(entry->value);
         bool composite = (type == QTYPE_QDICT || type == QTYPE_QLIST);
-        char key[strlen(entry->key) + 1];
+        char *key = g_malloc(strlen(entry->key) + 1);
         int i;
 
         /* replace dashes with spaces in key (variable) names */
@@ -683,6 +683,7 @@ static void dump_qdict(fprintf_function func_fprintf, void *f, int indentation,
         if (!composite) {
             func_fprintf(f, "\n");
         }
+        g_free(key);
     }
 }
 
This page took 0.024668 seconds and 4 git commands to generate.