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); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Showing the changes to kernel/debug (1 of 1 file). Show all
Unified · Split
| @@ -446,7 +446,7 @@ poll_again: · 445 unmodified lines | |||
| 446 | char *kdb_getstr(char *buffer, size_t bufsize, const char *prompt) | 446 | char *kdb_getstr(char *buffer, size_t bufsize, const char *prompt) |
| 447 | { | 447 | { |
| 448 | if (prompt && kdb_prompt_str != prompt) | 448 | if (prompt && kdb_prompt_str != prompt) |
| 449 | strncpy(kdb_prompt_str, prompt, CMD_BUFLEN); | 449 | strscpy(kdb_prompt_str, prompt, CMD_BUFLEN); |
| 450 | kdb_printf(kdb_prompt_str); | 450 | kdb_printf(kdb_prompt_str); |
| 451 | kdb_nextline = 1; /* Prompt and input resets line number */ | 451 | kdb_nextline = 1; /* Prompt and input resets line number */ |
| 452 | return kdb_read(buffer, bufsize); | 452 | return kdb_read(buffer, bufsize); |