Re: [PATCH] xfs: Use scnprintf() for avoiding potential buffer overflow

Takashi Iwai
2020-03-11T20:00:44Z

On Wed, 11 Mar 2020 19:21:36 +0100,
Darrick J. Wong wrote:
>
> On Wed, Mar 11, 2020 at 10:35:52AM +0100, Takashi Iwai wrote:
> > Since snprintf() returns the would-be-output size instead of the
> > actual output size, the succeeding calls may go beyond the given
> > buffer limit. Fix it by replacing with scnprintf().
>
> > Signed-off-by: Takashi Iwai <tiwai@suse.de>
>
> The 'c' in 'scnprintf' means that it returns the number of bytes written
> into the buffer (not including the \0) instead of the number of bytes
> that /would/ have been written provided there was enough space, right?

Yes.

Takashi