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

David Disseldorp
2023-12-27T13:34:53Z

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