NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: lib/58461: strtoi(3) is not portable
The following reply was made to PR lib/58461; it has been noted by GNATS.
From: Robert Elz <kre%munnari.OZ.AU@localhost>
To: gnats-bugs%netbsd.org@localhost
Cc:
Subject: Re: lib/58461: strtoi(3) is not portable
Date: Wed, 24 Jul 2024 08:38:28 +0700
The supplied patch is incorrect for NetBSD (and anywhere) as
when EINVAL is returned from strtoimax() (in the POSIX mandatory case,
to indicate an invalid base, as opposed to the POSIX optional case,
to indicate that no digits were converted) the value of *endptr is
unspecified, and hence cannot be compared to anything (and as it
happens, on NetBSD it gets set to nptr and so expecting it to remain
at any initial value is never going to work).
I have a different patch, which avoids the POSIX mandatory EINVAL
completely, by simply validating base before calling strtoimax(),
hence an EINVAL we do get from that (which now will never happen on
NetBSD) must be the optional one, so if it happens, we will simply
ignore that, and continue as if errno==0 had been returned (or more
correctly for strtoimax(), as if errno had not been altered, which
is the same thing with the strtoi() code).
Home |
Main Index |
Thread Index |
Old Index