Re: [PATCH v1 2/9] pktcdvd: replace sscanf() by kstrtoul()

From: 'Andy Shevchenko'
Date: Fri Jan 20 2023 - 06:49:56 EST


On Thu, Jan 19, 2023 at 10:40:12PM +0000, David Laight wrote:
> From: Andy Shevchenko
> > Sent: 19 January 2023 22:08

...

> > + ret = kstrtoint(buf, 10, &val);
> > + if (ret)
> > + return ret;

> These don't look directly equivalent.
> The sscanf() version silently ignores trailing characters.
> I think kstrtoint() will generate an error.

Yes, kstrtoint() is stricter than sscanf(), but I believe
that user space not so abusive. We may always return to
sscanf(), which I don't think would be good idea rather
than fixing the user space. But let's see...

> Have you actually checked that the caller allows for
> an error return.

_s_size_t somehow hints us about :-)

--
With Best Regards,
Andy Shevchenko