Alejandro Colomar
f2b240595b
lib/atoi/strtou_noneg.[ch]: Add strtou_noneg()
...
It's like strtou_(), but rejects negative input, instead of silently
converting it to unsigned.
Link: <https://softwareengineering.stackexchange.com/a/449060/332848 >
Signed-off-by: Alejandro Colomar <alx@kernel.org >
2024-01-31 22:26:19 -06:00
Alejandro Colomar
34ff8edb63
lib/atoi/strtoi.[ch]: strtoi_(), strtou_(): Add functions
...
These functions are identical to strtoi(3bsd) and strtou(3bsd), except
for one important thing: if both ERANGE and ENOTSUP conditions happen,
the BSD functions report ENOTSUP, which is bogus; our strtoi_() and
strtou_() report ERANGE.
Link: <https://lists.sr.ht/~hallyn/shadow/%3CZZoQDms6Sv6e5SPE%40debian%3E >
Link: <https://gnats.netbsd.org/cgi-bin/query-pr-single.pl?number=57828 >
Cc: Thorsten Glaser <tg@mirbsd.de >
Cc: christos <christos@netbsd.org >
Cc: roy <roy@netbsd.org >
Cc: Guillem Jover <guillem@hadrons.org >
Signed-off-by: Alejandro Colomar <alx@kernel.org >
2024-01-31 22:26:19 -06:00
Alejandro Colomar
4a2646f676
lib/atoi/strtou_noneg.[ch]: Add strtou[l]l_noneg()
...
These functions reject negative numbers, instead of silently converting
them into unsigned, which strtou[l]l(3) do.
Reviewed-by: Iker Pedrosa <ipedrosa@redhat.com >
Cc: "Serge E. Hallyn" <serge@hallyn.com >
Signed-off-by: Alejandro Colomar <alx@kernel.org >
2024-01-22 17:17:15 -06:00