lib/src/: a2i_strto[iu](): Check the base before strto[iu]max(3)

Some implementations of strto[iu]max(3) do modify *endptr if the base is
invalid.  Actually, glibc and musl are the weirdos that leave it
untouched, and all other systems I have checked (Bionic and the BSDs)
set it to nptr.

This means that it's impossible to portably detech an invalid base after
a call to strto[iu]max(3).  The base must be tested before the call.

Fixes: 8491813fee34 (2024-07-20, "lib/src/: a2i_strto[iu](): Pass the base to strto[iu]max(3)")
Reported-by: Robert Elz <kre@munnari.OZ.AU>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2 files changed