These are now merged to v5.2/*
Bruce
In message: [linux-yocto] [v5.2/standard/base][PATCH 1/3] kdb: Eliminate
strncpy() warnings by replacing with strscpy()
on 15/11/2020 wenlin.k...@windriver.com wrote:
> From: Daniel Thompson
>
> commit d228bee8201a7ea77c414f1298b2f572f42c6113 upstream
>
> Currently the code to manage the kdb history buffer uses strncpy() to
> copy strings to/and from the history and exhibits the classic "but
> nobody ever told me that strncpy() doesn't always terminate strings"
> bug. Modern gcc compilers recognise this bug and issue a warning.
>
> In reality these calls will only abridge the copied string if kdb_read()
> has *already* overflowed the command buffer. Thus the use of counted
> copies here is only used to reduce the secondary effects of a bug
> elsewhere in the code.
>
> Therefore transitioning these calls into strscpy() (without checking
> the return code) is appropriate.
>
> Signed-off-by: Daniel Thompson
> Reviewed-by: Douglas Anderson
> Signed-off-by: Wenlin Kang
> ---
> kernel/debug/kdb/kdb_main.c | 8
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
> index 9ecfa37c7fbf..bb5dec762b69 100644
> --- a/kernel/debug/kdb/kdb_main.c
> +++ b/kernel/debug/kdb/kdb_main.c
> @@ -1103,12 +1103,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);
> + strscpy(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);
> + strscpy(cmd_cur, cmd_hist[cmdptr], CMD_BUFLEN);
> return 1;
> }
> return 0;
> @@ -1315,7 +1315,7 @@ static int kdb_local(kdb_reason_t reason, int error,
> struct pt_regs *regs,
> if (*cmdbuf != '\n') {
> if (*cmdbuf < 32) {
> if (cmdptr == cmd_head) {
> - strncpy(cmd_hist[cmd_head], cmd_cur,
> + strscpy(cmd_hist[cmd_head], cmd_cur,
> CMD_BUFLEN);
> *(cmd_hist[cmd_head] +
> strlen(cmd_hist[cmd_head])-1) = '\0';
> @@ -1325,7 +1325,7 @@ static int kdb_local(kdb_reason_t reason, int error,
> struct pt_regs *regs,
> cmdbuf = cmd_cur;
> goto do_full_getstr;
> } else {
> - strncpy(cmd_hist[cmd_head], cmd_cur,
> + strscpy(cmd_hist[cmd_head], cmd_cur,
> CMD_BUFLEN);
> }
>
> --
> 2.17.1
>
>
>
>
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#9174):
https://lists.yoctoproject.org/g/linux-yocto/message/9174
Mute This Topic: https://lists.yoctoproject.org/mt/78367079/21656
Group Owner: linux-yocto+ow...@lists.yoctoproject.org
Unsubscribe: https://lists.yoctoproject.org/g/linux-yocto/unsub
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-