Actions
Bug #11326
openlibc: strtoul() forgets to set errno to EINVAL when no conversion could be performed
Start date:
2019-07-05
Due date:
% Done:
0%
Estimated time:
Difficulty:
Bite-size
Tags:
Gerrit CR:
External Bug:
Description
Found during the review of #11203.
From the strtoul (3C) manual page:
The strtoul() function may fail if: EINVAL No conversion could be performed.
This is missing from the implementation of
strtoul()
, [see here: /usr/src/common/util/strtoul.c, line 98], and just returns with zero.Note:
ddi_strtoul()
isn't affected.
Related issues
Updated by Garrett D'Amore over 4 years ago
So the EINVAL return value was added in XPG6 -- for older versions it wasn't specified. This is probably why it is called out that way.
Arguably we could probably just go ahead and do it unconditionally, software should be able to cope with this. But if we wanted to be thorough, we would only return EINVAL in that case if the code was built for XPG6 or XPG7.
Frankly, I'd like to get rid of the pre-XPG4 stuff, and maybe even just start doing XPG6 everywhere now. But that's a bigger discussion.
Updated by Gergő Mihály Doma over 4 years ago
- Related to Bug #1470: strtol doesn't set errno = EINVAL if conversion failed added
Actions