2013-04-07 11:21:20

by Chen Gang

[permalink] [raw]
Subject: [PATCH] kernel: debug: kdb: strncpy issue, using strlcpy instead of strncpy


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

Signed-off-by: Chen Gang <[email protected]>
---
kernel/debug/kdb/kdb_io.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/kernel/debug/kdb/kdb_io.c b/kernel/debug/kdb/kdb_io.c
index 14ff484..932b436 100644
--- a/kernel/debug/kdb/kdb_io.c
+++ b/kernel/debug/kdb/kdb_io.c
@@ -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);
--
1.7.7.6


2013-04-17 09:44:09

by Chen Gang

[permalink] [raw]
Subject: Re: [PATCH] kernel: debug: kdb: strncpy issue, using strlcpy instead of strncpy

Hello maintainers:

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

On 2013年04月07日 19:20, Chen Gang wrote:
>
> kdb_prompt_str is NUL terminated string, need always set '\0' at the end.
>
> Signed-off-by: Chen Gang <[email protected]>
> ---
> kernel/debug/kdb/kdb_io.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/kernel/debug/kdb/kdb_io.c b/kernel/debug/kdb/kdb_io.c
> index 14ff484..932b436 100644
> --- a/kernel/debug/kdb/kdb_io.c
> +++ b/kernel/debug/kdb/kdb_io.c
> @@ -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);
>


--
Chen Gang

Asianux Corporation