Re: [PATCH 1/3] kstrtox: introduce a safer version of memparse()

From: David Disseldorp
Date: Wed Dec 27 2023 - 08:35:05 EST


On Sat, 23 Dec 2023 20:28:05 +1030, Qu Wenruo wrote:

> + s = _parse_integer_fixup_radix(s, &base);
> + rv = _parse_integer(s, base, &value);
> + if (rv & KSTRTOX_OVERFLOW)
> + return -ERANGE;
> + if (rv == 0)
> + return -EINVAL;

I was playing around with your unit tests and noticed that "0xG" didn't
reach the expected rv == 0 -> -EINVAL above. It seems that
_parse_integer_fixup_radix() should handle 0x<non hex> differently, or
at least step past any autodetected '0' octal prefix.

Cheers, David