[<prev] [next>] [day] [month] [year] [list]
Message-Id: <1406385989-3976-1-git-send-email-rickard_strandqvist@spectrumdigital.se>
Date: Sat, 26 Jul 2014 16:46:29 +0200
From: Rickard Strandqvist <rickard_strandqvist@...ctrumdigital.se>
To: Jason Wessel <jason.wessel@...driver.com>,
Andrew Morton <akpm@...ux-foundation.org>
Cc: Rickard Strandqvist <rickard_strandqvist@...ctrumdigital.se>,
Randy Dunlap <rdunlap@...radead.org>,
Hedi Berriche <hedi@....com>, Mike Travis <travis@....com>,
Borislav Petkov <bp@...e.de>,
kgdb-bugreport@...ts.sourceforge.net, linux-kernel@...r.kernel.org
Subject: [PATCH] kernel: debug: kdb: kdb_main.c: Cleaning up missing null-terminate in conjunction with strncpy
Replacing strncpy with strlcpy to avoid strings that lacks null terminate.
Signed-off-by: Rickard Strandqvist <rickard_strandqvist@...ctrumdigital.se>
---
kernel/debug/kdb/kdb_main.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
index 2f7c760..b750c20 100644
--- a/kernel/debug/kdb/kdb_main.c
+++ b/kernel/debug/kdb/kdb_main.c
@@ -1063,12 +1063,12 @@ 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);
+ strlcpy(cmd_cur, cmd_hist[cmdptr], CMD_BUFLEN);
return 1;
case CTRL_N:
if (cmdptr != cmd_head)
cmdptr = (cmdptr+1) % KDB_CMD_HISTORY_COUNT;
- strncpy(cmd_cur, cmd_hist[cmdptr], CMD_BUFLEN);
+ strlcpy(cmd_cur, cmd_hist[cmdptr], CMD_BUFLEN);
return 1;
}
return 0;
@@ -1263,17 +1263,15 @@ do_full_getstr:
if (*cmdbuf != '\n') {
if (*cmdbuf < 32) {
if (cmdptr == cmd_head) {
- strncpy(cmd_hist[cmd_head], cmd_cur,
+ strlcpy(cmd_hist[cmd_head], cmd_cur,
CMD_BUFLEN);
- *(cmd_hist[cmd_head] +
- strlen(cmd_hist[cmd_head])-1) = '\0';
}
if (!handle_ctrl_cmd(cmdbuf))
*(cmd_cur+strlen(cmd_cur)-1) = '\0';
cmdbuf = cmd_cur;
goto do_full_getstr;
} else {
- strncpy(cmd_hist[cmd_head], cmd_cur,
+ strlcpy(cmd_hist[cmd_head], cmd_cur,
CMD_BUFLEN);
}
--
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