kdb: Fix bound check compiler warning
The strncpy() function may leave the destination string buffer unterminated, better use strscpy() instead. This fixes the following warning with gcc 8.2: kernel/debug/kdb/kdb_io.c: In function 'kdb_getstr': kernel/debug/kdb/kdb_io.c:449:3: warning: 'strncpy' specified bound 256 equals destination size [-Wstringop-truncation] strncpy(kdb_prompt_str, prompt, CMD_BUFLEN); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Wenlin Kang <wenlin.kang@windriver.com> Signed-off-by: Daniel Thompson <daniel.thompson@linaro.org>
This commit is contained in:
parent
b586627e10
commit
ca976bfb31
|
@ -446,7 +446,7 @@ poll_again:
|
||||||
char *kdb_getstr(char *buffer, size_t bufsize, const char *prompt)
|
char *kdb_getstr(char *buffer, size_t bufsize, const char *prompt)
|
||||||
{
|
{
|
||||||
if (prompt && kdb_prompt_str != prompt)
|
if (prompt && kdb_prompt_str != prompt)
|
||||||
strncpy(kdb_prompt_str, prompt, CMD_BUFLEN);
|
strscpy(kdb_prompt_str, prompt, CMD_BUFLEN);
|
||||||
kdb_printf(kdb_prompt_str);
|
kdb_printf(kdb_prompt_str);
|
||||||
kdb_nextline = 1; /* Prompt and input resets line number */
|
kdb_nextline = 1; /* Prompt and input resets line number */
|
||||||
return kdb_read(buffer, bufsize);
|
return kdb_read(buffer, bufsize);
|
||||||
|
|
Loading…
Reference in New Issue