Re: [PATCH] kernel: debug: kdb: strncpy issue, using strlcpy instead of strncpy.

2013-05-16 Thread Chen Gang
Hello Maintainers:

Please help check and apply this patch when you hanve time, thanks.

It is already Acked-by Anton, please see below.

Thanks.


On Wed, Apr 17, 2013 at 05:43:13PM +0800, Chen Gang wrote:
> Hello maintainers:
>
>   please help check this patch, when you have time, thanks.
>

The patch looks good. I would add to the description: "..., otherwise the
destination string might end up not being terminted with the NUL, causing
all sorts of misbehaviour."

Acked-by: Anton Vorontsov 

Thanks!

> On 2013年04月07日 19:03, Chen Gang wrote:
>>
>>   cmd_cur and cmd_hist[] are all NUL terminated string.
>>   need using strlcpy instead of strncpy.
>>
>> Signed-off-by: Chen Gang 
>> ---
>>  kernel/debug/kdb/kdb_main.c |8 
>>  1 files changed, 4 insertions(+), 4 deletions(-)
>>
>> diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
>> index 00eb8f7..a2b04d7 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;
>> @@ -1260,7 +1260,7 @@ 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';
>> @@ -1270,7 +1270,7 @@ do_full_getstr:
>>  cmdbuf = cmd_cur;
>>  goto do_full_getstr;
>>  } else {
>> -strncpy(cmd_hist[cmd_head], cmd_cur,
>> +strlcpy(cmd_hist[cmd_head], cmd_cur,
>>  CMD_BUFLEN);
>>  }
>>  
>>
>
>
> -- 
> Chen Gang
>
> Asianux Corporation




--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] kernel: debug: kdb: strncpy issue, using strlcpy instead of strncpy.

2013-05-16 Thread Chen Gang
Hello Maintainers:

Please help check and apply this patch when you hanve time, thanks.

It is already Acked-by Anton, please see below.

Thanks.


On Wed, Apr 17, 2013 at 05:43:13PM +0800, Chen Gang wrote:
 Hello maintainers:

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


The patch looks good. I would add to the description: ..., otherwise the
destination string might end up not being terminted with the NUL, causing
all sorts of misbehaviour.

Acked-by: Anton Vorontsov an...@enomsg.org

Thanks!

 On 2013年04月07日 19:03, Chen Gang wrote:

   cmd_cur and cmd_hist[] are all NUL terminated string.
   need using strlcpy instead of strncpy.

 Signed-off-by: Chen Gang gang.c...@asianux.com
 ---
  kernel/debug/kdb/kdb_main.c |8 
  1 files changed, 4 insertions(+), 4 deletions(-)

 diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
 index 00eb8f7..a2b04d7 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;
 @@ -1260,7 +1260,7 @@ 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';
 @@ -1270,7 +1270,7 @@ do_full_getstr:
  cmdbuf = cmd_cur;
  goto do_full_getstr;
  } else {
 -strncpy(cmd_hist[cmd_head], cmd_cur,
 +strlcpy(cmd_hist[cmd_head], cmd_cur,
  CMD_BUFLEN);
  }
  



 -- 
 Chen Gang

 Asianux Corporation




--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] kernel: debug: kdb: strncpy issue, using strlcpy instead of strncpy.

2013-04-23 Thread Chen Gang
On 2013年04月24日 04:50, Anton Vorontsov wrote:
> On Wed, Apr 17, 2013 at 05:43:13PM +0800, Chen Gang wrote:
>> > Hello maintainers:
>> > 
>> >   please help check this patch, when you have time, thanks.
>> > 
> The patch looks good. I would add to the description: "..., otherwise the
> destination string might end up not being terminted with the NUL, causing
> all sorts of misbehaviour."
> 
>   Acked-by: Anton Vorontsov 
> 
> Thanks!
> 

Thanks, also thank you for your additional description.

-- 
Chen Gang

Asianux Corporation
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] kernel: debug: kdb: strncpy issue, using strlcpy instead of strncpy.

2013-04-23 Thread Anton Vorontsov
On Wed, Apr 17, 2013 at 05:43:13PM +0800, Chen Gang wrote:
> Hello maintainers:
> 
>   please help check this patch, when you have time, thanks.
> 

The patch looks good. I would add to the description: "..., otherwise the
destination string might end up not being terminted with the NUL, causing
all sorts of misbehaviour."

Acked-by: Anton Vorontsov 

Thanks!

> On 2013年04月07日 19:03, Chen Gang wrote:
> > 
> >   cmd_cur and cmd_hist[] are all NUL terminated string.
> >   need using strlcpy instead of strncpy.
> > 
> > Signed-off-by: Chen Gang 
> > ---
> >  kernel/debug/kdb/kdb_main.c |8 
> >  1 files changed, 4 insertions(+), 4 deletions(-)
> > 
> > diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
> > index 00eb8f7..a2b04d7 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;
> > @@ -1260,7 +1260,7 @@ 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';
> > @@ -1270,7 +1270,7 @@ do_full_getstr:
> > cmdbuf = cmd_cur;
> > goto do_full_getstr;
> > } else {
> > -   strncpy(cmd_hist[cmd_head], cmd_cur,
> > +   strlcpy(cmd_hist[cmd_head], cmd_cur,
> > CMD_BUFLEN);
> > }
> >  
> > 
> 
> 
> -- 
> Chen Gang
> 
> Asianux Corporation
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] kernel: debug: kdb: strncpy issue, using strlcpy instead of strncpy.

2013-04-23 Thread Anton Vorontsov
On Wed, Apr 17, 2013 at 05:43:13PM +0800, Chen Gang wrote:
 Hello maintainers:
 
   please help check this patch, when you have time, thanks.
 

The patch looks good. I would add to the description: ..., otherwise the
destination string might end up not being terminted with the NUL, causing
all sorts of misbehaviour.

Acked-by: Anton Vorontsov an...@enomsg.org

Thanks!

 On 2013年04月07日 19:03, Chen Gang wrote:
  
cmd_cur and cmd_hist[] are all NUL terminated string.
need using strlcpy instead of strncpy.
  
  Signed-off-by: Chen Gang gang.c...@asianux.com
  ---
   kernel/debug/kdb/kdb_main.c |8 
   1 files changed, 4 insertions(+), 4 deletions(-)
  
  diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
  index 00eb8f7..a2b04d7 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;
  @@ -1260,7 +1260,7 @@ 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';
  @@ -1270,7 +1270,7 @@ do_full_getstr:
  cmdbuf = cmd_cur;
  goto do_full_getstr;
  } else {
  -   strncpy(cmd_hist[cmd_head], cmd_cur,
  +   strlcpy(cmd_hist[cmd_head], cmd_cur,
  CMD_BUFLEN);
  }
   
  
 
 
 -- 
 Chen Gang
 
 Asianux Corporation
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] kernel: debug: kdb: strncpy issue, using strlcpy instead of strncpy.

2013-04-23 Thread Chen Gang
On 2013年04月24日 04:50, Anton Vorontsov wrote:
 On Wed, Apr 17, 2013 at 05:43:13PM +0800, Chen Gang wrote:
  Hello maintainers:
  
please help check this patch, when you have time, thanks.
  
 The patch looks good. I would add to the description: ..., otherwise the
 destination string might end up not being terminted with the NUL, causing
 all sorts of misbehaviour.
 
   Acked-by: Anton Vorontsov an...@enomsg.org
 
 Thanks!
 

Thanks, also thank you for your additional description.

-- 
Chen Gang

Asianux Corporation
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] kernel: debug: kdb: strncpy issue, using strlcpy instead of strncpy.

2013-04-17 Thread Chen Gang
Hello maintainers:

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


On 2013年04月07日 19:03, Chen Gang wrote:
> 
>   cmd_cur and cmd_hist[] are all NUL terminated string.
>   need using strlcpy instead of strncpy.
> 
> Signed-off-by: Chen Gang 
> ---
>  kernel/debug/kdb/kdb_main.c |8 
>  1 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
> index 00eb8f7..a2b04d7 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;
> @@ -1260,7 +1260,7 @@ 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';
> @@ -1270,7 +1270,7 @@ do_full_getstr:
>   cmdbuf = cmd_cur;
>   goto do_full_getstr;
>   } else {
> - strncpy(cmd_hist[cmd_head], cmd_cur,
> + strlcpy(cmd_hist[cmd_head], cmd_cur,
>   CMD_BUFLEN);
>   }
>  
> 


-- 
Chen Gang

Asianux Corporation
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


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

2013-04-17 Thread Chen Gang
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 
> ---
>  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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] kernel: debug: kdb: strncpy issue, using strlcpy instead of strncpy.

2013-04-17 Thread Chen Gang
Hello maintainers:

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


On 2013年04月07日 19:03, Chen Gang wrote:
 
   cmd_cur and cmd_hist[] are all NUL terminated string.
   need using strlcpy instead of strncpy.
 
 Signed-off-by: Chen Gang gang.c...@asianux.com
 ---
  kernel/debug/kdb/kdb_main.c |8 
  1 files changed, 4 insertions(+), 4 deletions(-)
 
 diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
 index 00eb8f7..a2b04d7 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;
 @@ -1260,7 +1260,7 @@ 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';
 @@ -1270,7 +1270,7 @@ do_full_getstr:
   cmdbuf = cmd_cur;
   goto do_full_getstr;
   } else {
 - strncpy(cmd_hist[cmd_head], cmd_cur,
 + strlcpy(cmd_hist[cmd_head], cmd_cur,
   CMD_BUFLEN);
   }
  
 


-- 
Chen Gang

Asianux Corporation
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


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

2013-04-17 Thread Chen Gang
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 gang.c...@asianux.com
 ---
  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
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


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

2013-04-07 Thread Chen Gang

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

Signed-off-by: Chen Gang 
---
 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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] kernel: debug: kdb: strncpy issue, using strlcpy instead of strncpy.

2013-04-07 Thread Chen Gang

  cmd_cur and cmd_hist[] are all NUL terminated string.
  need using strlcpy instead of strncpy.

Signed-off-by: Chen Gang 
---
 kernel/debug/kdb/kdb_main.c |8 
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
index 00eb8f7..a2b04d7 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;
@@ -1260,7 +1260,7 @@ 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';
@@ -1270,7 +1270,7 @@ do_full_getstr:
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.7.6
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] kernel: debug: kdb: strncpy issue, using strlcpy instead of strncpy.

2013-04-07 Thread Chen Gang

  cmd_cur and cmd_hist[] are all NUL terminated string.
  need using strlcpy instead of strncpy.

Signed-off-by: Chen Gang gang.c...@asianux.com
---
 kernel/debug/kdb/kdb_main.c |8 
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
index 00eb8f7..a2b04d7 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;
@@ -1260,7 +1260,7 @@ 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';
@@ -1270,7 +1270,7 @@ do_full_getstr:
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.7.6
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


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

2013-04-07 Thread Chen Gang

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

Signed-off-by: Chen Gang gang.c...@asianux.com
---
 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
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/