lkml.org 
[lkml]   [2023]   [Oct]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] net/mlx5: simplify mlx5_set_driver_version string assignments
On 11 Oct 14:34, Kees Cook wrote:
>On Wed, Oct 11, 2023 at 09:29:57PM +0000, Justin Stitt wrote:
>> In total, just assigning this version string takes:
>> (1) strncpy()'s
>> (5) strlen()'s
>> (3) strncat()'s
>> (1) snprintf()'s
>> (4) max_t()'s
>>
>> Moreover, `strncpy` is deprecated [1] and `strncat` really shouldn't be
>> used either [2]. With this in mind, let's simply use a single
>> `snprintf`.
>
>Yes, please! readability++
>
>>
>> Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strncpy-on-nul-terminated-strings [1]
>> Link: https://elixir.bootlin.com/linux/v6.6-rc5/source/include/linux/fortify-string.h#L448 [2]
>> Link: https://github.com/KSPP/linux/issues/90
>> Cc: linux-hardening@vger.kernel.org
>> Cc: Kees Cook <keescook@chromium.org>
>> Signed-off-by: Justin Stitt <justinstitt@google.com>
>
>Reviewed-by: Kees Cook <keescook@chromium.org>

Applied to net-next-mlx5.

\
 
 \ /
  Last update: 2023-10-12 21:46    [W:0.053 / U:0.232 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site