Re: [PATCH] accessibility: speakup: Fix incorrect string length computation in report_char_chartab_status()

From: Dan Carpenter
Date: Wed Sep 06 2023 - 05:09:39 EST


On Mon, Sep 04, 2023 at 09:31:44PM +0200, Christophe JAILLET wrote:
> snprintf() returns the "number of characters which *would* be generated for
> the given input", not the size *really* generated.
>
> In order to avoid too large values for 'len' (and potential negative
> values for "sizeof(buf) - (len - 1)") use scnprintf() instead of
> snprintf().
>

A bunch of kernel-janitors mail didn't reach my inbox... Like this
one. So weird.

Reviewed-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>

The impact of this bug is a WARN() btw. snprintf() will refuse to
print negative bytes.

regards,
dan carpenter