Re: [PATCH v1] xstrtol: 1 is not a valid base

Bruno Haible <[email protected]> Thu, 18 Jul 2024 20:06:07 +0200
Newsgroups dev.linux.lists.liba2i
Message-ID <2143892.otsE0voPBg@nimes>
Alejandro Colomar wrote:
> If xstrtol() was being called with a base of 1, under some conditions it
> would invoke Undefined Behavior.

Yes, sure. A numeric base of 1 makes no sense, mathematically.

Thanks for the patch; applied.

Note that I disagree with the statement from
https://github.com/void-linux/void-packages/issues/51261#issuecomment-2237055195 :
> Yet he introduced that bug a decade ago

I wouldn't call it a bug. Gnulib does not document that passing a base of 1
to xstrtol is valid. It's known to everyone in the field that a base of 1
makes no sense. So, what you saw here was a slightly incomplete input
validation check.

Thanks for the improvement.

Bruno