jail: fix segfault with len(uidmap/gidmap) > 1
authorDaniel Golle <daniel@makrotopia.org>
Sun, 12 Jul 2020 16:36:05 +0000 (17:36 +0100)
committerDaniel Golle <daniel@makrotopia.org>
Mon, 13 Jul 2020 11:14:49 +0000 (12:14 +0100)
Allocate enough memory for all uidmap/gidmap entries.

Fixes: ea7a790 ("jail: add support for running OCI bundle")
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
jail/jail.c

index 8a2d890dcab7a56fdd93920c6a7950a1745b432a..aa9285c88dc896743a11583fc0dd20a71c59ef56 100644 (file)
@@ -1105,7 +1105,7 @@ static int parseOCIuidgidmappings(struct blob_attr *msg, bool is_gidmap)
        }
 
        /* allocate combined mapping string */
-       map = calloc(1 + len, sizeof(char));
+       map = calloc(1 + totallen, sizeof(char));
        if (!map)
                return ENOMEM;