Re: [PATCH v1 1/1] seq_file: Replace strncpy()+nul by strscpy()

From: Kees Cook
Date: Mon Jul 17 2023 - 19:10:29 EST



On Mon, 17 Jul 2023 12:33:32 +0300, Andy Shevchenko wrote:
> Privided seq_show_option_n() macro breaks build with -Werror
> and W=1, e.g.:
>
> In function ‘strncpy’,
> inlined from ‘ocfs2_show_options’ at fs/ocfs2/super.c:1520:3:
> include/linux/fortify-string.h:68:33: error: ‘__builtin_strncpy’ output may be truncated copying 4 bytes from a string of length 4 [-Werror=stringop-truncation]
> 68 | #define __underlying_strncpy __builtin_strncpy
> | ^
> include/linux/fortify-string.h:151:16: note: in expansion of macro ‘__underlying_strncpy’
> 151 | return __underlying_strncpy(p, q, size);
> | ^~~~~~~~~~~~~~~~~~~~
> cc1: all warnings being treated as errors
>
> [...]

Applied, thanks!

[1/1] seq_file: Replace strncpy()+nul by strscpy()
https://git.kernel.org/kees/c/c30417b20f49

Best regards,
--
Kees Cook