[PATCH] arch: powerpc: kernel: nvram_64.c: Cleaning up missing null-terminate in conjunction with strncpy
Rickard Strandqvist
rickard_strandqvist at spectrumdigital.se
Sun Jul 27 02:43:32 EST 2014
Replacing strncpy with strlcpy to avoid strings that lacks null terminate.
And removed unnecessary magic numbers.
Signed-off-by: Rickard Strandqvist <rickard_strandqvist at spectrumdigital.se>
---
arch/powerpc/kernel/nvram_64.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/powerpc/kernel/nvram_64.c b/arch/powerpc/kernel/nvram_64.c
index 28b898e..5ed7b74 100644
--- a/arch/powerpc/kernel/nvram_64.c
+++ b/arch/powerpc/kernel/nvram_64.c
@@ -292,7 +292,7 @@ int __init nvram_remove_partition(const char *name, int sig,
/* Make partition a free partition */
part->header.signature = NVRAM_SIG_FREE;
- strncpy(part->header.name, "wwwwwwwwwwww", 12);
+ strlcpy(part->header.name, "wwwwwwwwwwww", sizeof(part->header.name));
part->header.checksum = nvram_checksum(&part->header);
rc = nvram_write_header(part);
if (rc <= 0) {
@@ -395,7 +395,7 @@ loff_t __init nvram_create_partition(const char *name, int sig,
new_part->index = free_part->index;
new_part->header.signature = sig;
new_part->header.length = size;
- strncpy(new_part->header.name, name, 12);
+ strlcpy(new_part->header.name, name, sizeof(new_part->header.name));
new_part->header.checksum = nvram_checksum(&new_part->header);
rc = nvram_write_header(new_part);
--
1.7.10.4
More information about the Linuxppc-dev
mailing list