Skip to contentSkip to conversation

proc: kcore: using strlcpy instead of strncpy

PATCH New Zhao Hongjiang 1 participant 1 message Jun 20, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 proc: kcore: using strlcpy instead of strncpy

for NUL terminated string, need alway set '\0' in the end.

---
 fs/proc/kcore.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
fs/proc/kcore.c +1 -1
index 0a22194..06ea155 100644
@@ -408,7 +408,7 @@ static void elf_kcore_store_hdr(char *bufp, int nphdr, int dataoff)
 	prpsinfo.pr_zomb	= 0;
 
 	strcpy(prpsinfo.pr_fname, "vmlinux");
-	strncpy(prpsinfo.pr_psargs, saved_command_line, ELF_PRARGSZ);
+	strlcpy(prpsinfo.pr_psargs, saved_command_line, sizeof(prpsinfo.pr_psargs));
 
 	nhdr->p_filesz	+= notesize(&notes[1]);
 	bufp = storenote(&notes[1], bufp);
Signature · 1 line
1.7.1