Skip to content

Commit c9babd5

Browse files
JustinStittingomolnar
authored andcommitted
x86/tdx: Replace deprecated strncpy() with strtomem_pad()
strncpy() works perfectly here in all cases, however, it is deprecated and as such we should prefer more robust and less ambiguous string APIs: https://www.kernel.org/doc/html/latest/process/deprecated.html#strncpy-on-nul-terminated-strings Let's use strtomem_pad() as this matches the functionality of strncpy() and is _not_ deprecated. Signed-off-by: Justin Stitt <justinstitt@google.com> Signed-off-by: Ingo Molnar <mingo@kernel.org> Reviewed-by: Kees Cook <keescook@chromium.org> Acked-by: Dave Hansen <dave.hansen@linux.intel.com> Link: KSPP#90 Link: https://lore.kernel.org/r/20231003-strncpy-arch-x86-coco-tdx-tdx-c-v2-1-0bd21174a217@google.com
1 parent 802e87c commit c9babd5

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

arch/x86/coco/tdx/tdx.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ static void __noreturn tdx_panic(const char *msg)
119119
} message;
120120

121121
/* VMM assumes '\0' in byte 65, if the message took all 64 bytes */
122-
strncpy(message.str, msg, 64);
122+
strtomem_pad(message.str, msg, '\0');
123123

124124
args.r8 = message.r8;
125125
args.r9 = message.r9;

0 commit comments

Comments
 (0)