Skip to contentSkip to conversation

kernel: debug: kdb: strncpy issue, using strlcpy instead of strncpy

PATCH In review Chen Gang 1 participant 2 messages Apr 7, 2013 – Apr 17, 2013 KGDB / KDB /debug_core

lore
Share & tools
lore

Chen Gang

author
#0 lore raw

PATCH 1/1 kernel: debug: kdb: strncpy issue, using strlcpy instead of strncpy

kdb_prompt_str is NUL terminated string, need always set '\0' at the end.

---
 kernel/debug/kdb/kdb_io.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
kernel/debug/kdb/kdb_io.c +1 -1
index 14ff484..932b436 100644
@@ -442,7 +442,7 @@ poll_again:
 char *kdb_getstr(char *buffer, size_t bufsize, char *prompt)
 {
 	if (prompt && kdb_prompt_str != prompt)
-		strncpy(kdb_prompt_str, prompt, CMD_BUFLEN);
+		strlcpy(kdb_prompt_str, prompt, CMD_BUFLEN);
 	kdb_printf(kdb_prompt_str);
 	kdb_nextline = 1;	/* Prompt and input resets line number */
 	return kdb_read(buffer, bufsize);
Signature · 1 line
1.7.7.6
author
#1 lore raw

Hello maintainers:

please help check this patch, when you have time, thanks.

Quoted 22 lines · Chen Gang

kdb_prompt_str is NUL terminated string, need always set '\0' at the end.

---
 kernel/debug/kdb/kdb_io.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
kernel/debug/kdb/kdb_io.c +1 -1
index 14ff484..932b436 100644
@@ -442,7 +442,7 @@ poll_again:
 char *kdb_getstr(char *buffer, size_t bufsize, char *prompt)
 {
 	if (prompt && kdb_prompt_str != prompt)
-		strncpy(kdb_prompt_str, prompt, CMD_BUFLEN);
+		strlcpy(kdb_prompt_str, prompt, CMD_BUFLEN);
 	kdb_printf(kdb_prompt_str);
 	kdb_nextline = 1;	/* Prompt and input resets line number */
 	return kdb_read(buffer, bufsize);
Signature · 3 lines
Chen Gang

Asianux Corporation