Skip to contentSkip to conversation

arch: mips: kernel: using strlcpy() instead of strncpy()

PATCH Superseded Chen Gang 2 participants 2 messages May 26, 2013 – May 27, 2013

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Chen Gang

author
#0 lore raw

PATCH 1/1 arch: mips: kernel: using strlcpy() instead of strncpy()

For NUL terminated string, need always be sure of ended by zero.

Or the next pr_info() will cause issue.

---
 arch/mips/kernel/prom.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
arch/mips/kernel/prom.c +1 -1
index 5712bb5..7e95404 100644
@@ -30,7 +30,7 @@ __init void mips_set_machine_name(const char *name)
 	if (name == NULL)
 		return;
 
-	strncpy(mips_machine_name, name, sizeof(mips_machine_name));
+	strlcpy(mips_machine_name, name, sizeof(mips_machine_name));
 	pr_info("MIPS: machine is %s\n", mips_get_machine_name());
 }
 
Signature · 1 line
1.7.7.6
Acked-by on v1 1/1
#1 lore raw
Quoted 15 lines · Chen Gang

For NUL terminated string, need always be sure of ended by zero.

Or the next pr_info() will cause issue.

---
  arch/mips/kernel/prom.c |    2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)
arch/mips/kernel/prom.c +0 -0
index 5712bb5..7e95404 100644

arch/mips/kernel/prom.c __init void mips_set_machine_name(const char *name) · line 36

Quoted 8 lines
arch/mips/kernel/prom.c +1 -1
@@ -30,7 +30,7 @@ __init void mips_set_machine_name(const char *name)
  	if (name == NULL)
  		return;
 
-	strncpy(mips_machine_name, name, sizeof(mips_machine_name));
+	strlcpy(mips_machine_name, name, sizeof(mips_machine_name));
  	pr_info("MIPS: machine is %s\n", mips_get_machine_name());
  }