diff options
author | Justin Stitt <justinstitt@google.com> | 2023-08-16 21:39:24 +0000 |
---|---|---|
committer | Michael Ellerman <mpe@ellerman.id.au> | 2023-08-18 11:48:42 +1000 |
commit | f94a84a0914841d79a38df7cc75512d88b31a0dc (patch) | |
tree | 9507c09d98e1f827c5e346358cbcb890733debdc /arch/powerpc/platforms/ps3 | |
parent | 9a32584bc108c8fe4d02fa33b16caf686e4a788a (diff) | |
download | linux-f94a84a0914841d79a38df7cc75512d88b31a0dc.tar.gz linux-f94a84a0914841d79a38df7cc75512d88b31a0dc.tar.bz2 linux-f94a84a0914841d79a38df7cc75512d88b31a0dc.zip |
powerpc/ps3: refactor strncpy usage
`strncpy` is deprecated for use on NUL-terminated destination strings [1].
`make_first_field()` should use similar implementation to `make_field()`
due to memcpy having more obvious behavior here. The end result yields
the same behavior as the previous `strncpy`-based implementation
including the NUL-padding.
Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strncpy-on-nul-terminated-strings [1]
Link: https://github.com/KSPP/linux/issues/90
Signed-off-by: Justin Stitt <justinstitt@google.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
Tested-by: Geoff Levand <geoff@infradead.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://msgid.link/20230816-strncpy-arch-powerpc-platforms-ps3-repository-v1-1-88283b02fb09@google.com
Diffstat (limited to 'arch/powerpc/platforms/ps3')
-rw-r--r-- | arch/powerpc/platforms/ps3/repository.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/arch/powerpc/platforms/ps3/repository.c b/arch/powerpc/platforms/ps3/repository.c index 205763061a2d..1abe33fbe529 100644 --- a/arch/powerpc/platforms/ps3/repository.c +++ b/arch/powerpc/platforms/ps3/repository.c @@ -73,9 +73,9 @@ static void _dump_node(unsigned int lpar_id, u64 n1, u64 n2, u64 n3, u64 n4, static u64 make_first_field(const char *text, u64 index) { - u64 n; + u64 n = 0; - strncpy((char *)&n, text, 8); + memcpy((char *)&n, text, strnlen(text, sizeof(n))); return PS3_VENDOR_ID_NONE + (n >> 32) + index; } |