platform: generic: Terminate platform.name with null
authorBin Meng <bmeng.cn@gmail.com>
Sun, 4 Jul 2021 15:01:13 +0000 (23:01 +0800)
committerAnup Patel <anup@brainfault.org>
Tue, 6 Jul 2021 08:51:53 +0000 (14:21 +0530)
fw_platform_init() fills platform.name without considering the
ending null character. Fix it.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
platform/generic/platform.c

index da0c1af..79d5230 100644 (file)
@@ -85,7 +85,7 @@ unsigned long fw_platform_init(unsigned long arg0, unsigned long arg1,
 
        model = fdt_getprop(fdt, root_offset, "model", &len);
        if (model)
-               sbi_strncpy(platform.name, model, sizeof(platform.name));
+               sbi_strncpy(platform.name, model, sizeof(platform.name) - 1);
 
        if (generic_plat && generic_plat->features)
                platform.features = generic_plat->features(generic_plat_match);