cmd: pxe: use strdup to copy config
authorPatrick Delaunay <patrick.delaunay@foss.st.com>
Fri, 28 Oct 2022 09:01:20 +0000 (11:01 +0200)
committerTom Rini <trini@konsulko.com>
Mon, 12 Dec 2022 19:03:12 +0000 (14:03 -0500)
Replace malloc and strcpy by strdup in
function parse_label_kernel.

Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>
boot/pxe_utils.c

index b59e959..c613818 100644 (file)
@@ -1179,11 +1179,10 @@ static int parse_label_kernel(char **c, struct pxe_label *label)
        if (!s)
                return 1;
 
-       label->config = malloc(strlen(s) + 1);
+       label->config = strdup(s);
        if (!label->config)
                return -ENOMEM;
 
-       strcpy(label->config, s);
        *s = 0;
 
        return 1;