]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
kdb: Replace deprecated strcpy() with memcpy() in parse_grep()
authorThorsten Blum <thorsten.blum@linux.dev>
Tue, 19 Aug 2025 09:59:05 +0000 (11:59 +0200)
committerDaniel Thompson (RISCstar) <danielt@kernel.org>
Sat, 20 Sep 2025 18:56:28 +0000 (19:56 +0100)
strcpy() is deprecated; use memcpy() instead.

We can safely use memcpy() because we already know the length of the
source string 'cp' and that it is guaranteed to be NUL-terminated within
the first KDB_GREP_STRLEN bytes.

Link: https://github.com/KSPP/linux/issues/88
Reviewed-by: Douglas Anderson <dianders@chromium.org>
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Signed-off-by: Daniel Thompson (RISCstar) <danielt@kernel.org>
kernel/debug/kdb/kdb_main.c

index 7a4d2d4689a579d6b0a6edb6928c158ffa6aaec7..cdf91976eb7cdc4eaa903ad8eb407658a329d24e 100644 (file)
@@ -860,7 +860,7 @@ static void parse_grep(const char *str)
                kdb_printf("search string too long\n");
                return;
        }
-       strcpy(kdb_grep_string, cp);
+       memcpy(kdb_grep_string, cp, len + 1);
        kdb_grepping_flag++;
        return;
 }