The pxe_utils/label_boot_extension calls snprintf on an uninitialized memory 
overlay_dir.
This results in a crash when calling sysboot.

This commit fixes this issue.

Signed-off-by: Surkov Kirill <[email protected]>
---
 boot/pxe_utils.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c
index 038416203fc..fc72dbf6020 100644
--- a/boot/pxe_utils.c
+++ b/boot/pxe_utils.c
@@ -463,6 +463,8 @@ static void label_boot_extension(struct pxe_context *ctx,
        if (fdt_check_header(working_fdt))
                return;
 
+       overlay_dir = calloc(1, len);
+
        /* Use fdtdir for now as the overlay devicetree directory */
        if (label->fdtdir) {
                len = strlen(label->fdtdir);
@@ -474,7 +476,6 @@ static void label_boot_extension(struct pxe_context *ctx,
                        slash = "";
 
                dir_len = strlen(label->fdtdir) + strlen(slash) + 1;
-               overlay_dir = calloc(1, len);
                if (!overlay_dir)
                        return;
 
-- 
2.43.0

Reply via email to