[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <171400286686.3283788.1185955927816230605.b4-ty@chromium.org>
Date: Wed, 24 Apr 2024 16:54:36 -0700
From: Kees Cook <keescook@...omium.org>
To: reiserfs-devel@...r.kernel.org,
linux-kernel@...r.kernel.org,
Justin Stitt <justinstitt@...gle.com>
Cc: Kees Cook <keescook@...omium.org>,
linux-hardening@...r.kernel.org
Subject: Re: [PATCH] reiserfs: replace deprecated strncpy with scnprintf
On Thu, 28 Mar 2024 21:16:52 +0000, Justin Stitt wrote:
> strncpy() is deprecated for use on NUL-terminated destination strings
> [1] and as such we should prefer more robust and less ambiguous string
> interfaces.
>
> Our goal here is to get @namebuf populated with @name's contents but
> surrounded with quotes. There is some careful handling done to ensure we
> properly truncate @name so that we have room for a literal quote as well
> as a NUL-term. All this careful handling can be done with scnprintf
> using the dynamic string width specifier %.*s which allows us to pass in
> the max size for a source string. Doing this, we can put literal quotes
> in our format specifier and ensure @name is truncated to fit inbetween
> these quotes (-3 is from 2 quotes + 1 NUL-byte).
>
> [...]
Applied to for-next/hardening, thanks!
[1/1] reiserfs: replace deprecated strncpy with scnprintf
https://git.kernel.org/kees/c/ba287092ae90
Take care,
--
Kees Cook
Powered by blists - more mailing lists