[<prev] [next>] [day] [month] [year] [list]
Message-Id: <1401918096-3516-1-git-send-email-rickard_strandqvist@spectrumdigital.se>
Date: Wed, 4 Jun 2014 23:41:36 +0200
From: Rickard Strandqvist <rickard_strandqvist@...ctrumdigital.se>
To: Jason Wessel <jason.wessel@...driver.com>,
Rickard Strandqvist <rickard_strandqvist@...ctrumdigital.se>
Cc: kgdb-bugreport@...ts.sourceforge.net, linux-kernel@...r.kernel.org
Subject: [PATCH] kernel: debug: kdb: kdb_io.c: Cleaning up missing null-terminate after strncpy call
Added a guaranteed null-terminate after call to strncpy.
This was partly found using a static code analysis program called cppcheck.
Signed-off-by: Rickard Strandqvist <rickard_strandqvist@...ctrumdigital.se>
---
kernel/debug/kdb/kdb_io.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/kernel/debug/kdb/kdb_io.c b/kernel/debug/kdb/kdb_io.c
index 14ff484..0cd0e28 100644
--- a/kernel/debug/kdb/kdb_io.c
+++ b/kernel/debug/kdb/kdb_io.c
@@ -441,8 +441,10 @@ 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);
+ if (prompt && kdb_prompt_str != prompt) {
+ strncpy(kdb_prompt_str, prompt, sizeof(kdb_prompt_str));
+ kdb_prompt_str[sizeof(kdb_prompt_str) - 1] = '\0'
+ }
kdb_printf(kdb_prompt_str);
kdb_nextline = 1; /* Prompt and input resets line number */
return kdb_read(buffer, bufsize);
--
1.7.10.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists