[<prev] [next>] [day] [month] [year] [list]
Message-Id: <1401918189-3607-1-git-send-email-rickard_strandqvist@spectrumdigital.se>
Date: Wed, 4 Jun 2014 23:43:09 +0200
From: Rickard Strandqvist <rickard_strandqvist@...ctrumdigital.se>
To: Jason Wessel <jason.wessel@...driver.com>,
Rickard Strandqvist <rickard_strandqvist@...ctrumdigital.se>
Cc: Hedi Berriche <hedi@....com>, Mike Travis <travis@....com>,
Ingo Molnar <mingo@...nel.org>,
kgdb-bugreport@...ts.sourceforge.net, linux-kernel@...r.kernel.org
Subject: [PATCH] kernel: debug: kdb: kdb_main.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_main.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
index 0b097c8..736b025 100644
--- a/kernel/debug/kdb/kdb_main.c
+++ b/kernel/debug/kdb/kdb_main.c
@@ -1063,12 +1063,14 @@ static int handle_ctrl_cmd(char *cmd)
case CTRL_P:
if (cmdptr != cmd_tail)
cmdptr = (cmdptr-1) % KDB_CMD_HISTORY_COUNT;
- strncpy(cmd_cur, cmd_hist[cmdptr], CMD_BUFLEN);
+ strncpy(cmd_cur, cmd_hist[cmdptr], sizeof(cmd_cur));
+ cmd_cur[sizeof(cmd_cur) - 1] = '\0';
return 1;
case CTRL_N:
if (cmdptr != cmd_head)
cmdptr = (cmdptr+1) % KDB_CMD_HISTORY_COUNT;
- strncpy(cmd_cur, cmd_hist[cmdptr], CMD_BUFLEN);
+ strncpy(cmd_cur, cmd_hist[cmdptr], sizeof(cmd_cur));
+ cmd_cur[sizeof(cmd_cur) - 1] = '\0';
return 1;
}
return 0;
--
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