On Mon, Jan 14, 2019 at 5:02 PM Kees Cook <[email protected]> wrote:
> On Sat, Jan 12, 2019 at 7:28 AM Willy Tarreau <[email protected]> wrote:
> > From: Silvio Cesare <[email protected]>
> > Change snprintf to scnprintf. There are generally two cases where using
> > snprintf causes problems.
>
> (I didn't find a 0/8 cover letter, so I'm replying here...)

I forgot to mention: can we please get a Coccinelle rule added to
catch these cases in the future? (And make sure sfr is running it? :)
)

My attempt at it was:

@@
expression LEN, BUF, SIZE;
identifier FUNC;
@@

  LEN += snprintf(BUF + LEN, SIZE - LEN, ...);
  ... when != LEN &gt; SIZE
      when != LEN &gt;= SIZE
* FUNC(..., LEN, ...)

But this needs adjustment to deal with some false positives (like using min()).

--
Kees Cook

Reply via email to