Project

General

Profile

Bug #11326

libc: strtoul() forgets to set errno to EINVAL when no conversion could be performed

Added by Gergő Mihály Doma over 1 year ago. Updated over 1 year ago.

Status:
New
Priority:
Normal
Category:
lib - userland libraries
Start date:
2019-07-05
Due date:
% Done:

0%

Estimated time:
Difficulty:
Bite-size
Tags:
Gerrit CR:

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

Related to illumos gate - Bug #1470: strtol doesn't set errno = EINVAL if conversion failedResolved2011-09-05

Actions

History

#1

Updated by Garrett D'Amore over 1 year 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.

#2

Updated by Gergő Mihály Doma over 1 year ago

  • Related to Bug #1470: strtol doesn't set errno = EINVAL if conversion failed added

Also available in: Atom PDF