Skip to contentSkip to conversation

platform: generic: Terminate platform.name with null

PATCH New Bin Meng 2 participants 2 messages Jul 4, 2021 – Jul 6, 2021

lore
Share & tools
lore

Bin Meng

author
#0 lore raw

PATCH 1/1 platform: generic: Terminate platform.name with null

fw_platform_init() fills platform.name without considering the ending null character. Fix it.

---

 platform/generic/platform.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
platform/generic/platform.c +1 -1
index da0c1af..79d5230 100644
@@ -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);
Signature · 1 line
2.25.1
Applied
#1 lore raw

PATCH 1/1 platform: generic: Terminate platform.name with null

Quoted 5 lines · Bin Meng

fw_platform_init() fills platform.name without considering the ending null character. Fix it.

Looks good to me.

Applied this patch to the riscv/opensbi repo

Thanks,
Anup

Quoted 26 lines

---

 platform/generic/platform.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
platform/generic/platform.c +1 -2
index da0c1af..79d5230 100644
@@ -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);
--

2.25.1

--
opensbi mailing list
opensbi at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi