Re: [PATCH v4] checkpatch: add check for snprintf to scnprintf

2024-04-15 Thread Kees Cook
On Thu, Apr 11, 2024 at 03:10:57PM -0700, Justin Stitt wrote: > On Thu, Apr 11, 2024 at 1:56 PM Joe Perches wrote: > > It could. > > > > # {v}snprintf uses that should likely be {v}scnprintf > > if ($line =~ /\b((v?)snprintf)\s*\(/) { > > WARN("SNPRINTF", >

Re: [PATCH v4] checkpatch: add check for snprintf to scnprintf

2024-04-11 Thread Justin Stitt
On Thu, Apr 11, 2024 at 1:56 PM Joe Perches wrote: > It could. > > # {v}snprintf uses that should likely be {v}scnprintf > if ($line =~ /\b((v?)snprintf)\s*\(/) { > WARN("SNPRINTF", > "Prefer ${2}scnprintf over $1 - see: >

Re: [PATCH v4] checkpatch: add check for snprintf to scnprintf

2024-04-11 Thread Christophe JAILLET
Le 08/04/2024 à 22:53, Justin Stitt a écrit : I am going to quote Lee Jones who has been doing some snprintf -> scnprintf refactorings: "There is a general misunderstanding amongst engineers that {v}snprintf() returns the length of the data *actually* encoded into the destination array.

Re: [PATCH v4] checkpatch: add check for snprintf to scnprintf

2024-04-11 Thread Joe Perches
On Thu, 2024-04-11 at 22:01 +0200, Christophe JAILLET wrote: > Le 08/04/2024 à 22:53, Justin Stitt a écrit : > > I am going to quote Lee Jones who has been doing some snprintf -> > > scnprintf refactorings: > > > > "There is a general misunderstanding amongst engineers that > > {v}snprintf()

Re: [PATCH v4] checkpatch: add check for snprintf to scnprintf

2024-04-11 Thread Lee Jones
On Mon, 08 Apr 2024, Justin Stitt wrote: > I am going to quote Lee Jones who has been doing some snprintf -> > scnprintf refactorings: > > "There is a general misunderstanding amongst engineers that > {v}snprintf() returns the length of the data *actually* encoded into the > destination array.

Re: [PATCH v4] checkpatch: add check for snprintf to scnprintf

2024-04-08 Thread Kees Cook
On Mon, Apr 08, 2024 at 08:53:33PM +, Justin Stitt wrote: > I am going to quote Lee Jones who has been doing some snprintf -> > scnprintf refactorings: > > "There is a general misunderstanding amongst engineers that > {v}snprintf() returns the length of the data *actually* encoded into the >

[PATCH v4] checkpatch: add check for snprintf to scnprintf

2024-04-08 Thread Justin Stitt
I am going to quote Lee Jones who has been doing some snprintf -> scnprintf refactorings: "There is a general misunderstanding amongst engineers that {v}snprintf() returns the length of the data *actually* encoded into the destination array. However, as per the C99 standard {v}snprintf() really