diff options
| author | Alejandro Colomar <alx@kernel.org> | 2025-03-21 21:35:52 +0100 |
|---|---|---|
| committer | Alejandro Colomar <alx@kernel.org> | 2025-03-23 14:56:53 +0100 |
| commit | cbcf76d19f864da8c54e41b600ff5661b195b58e (patch) | |
| tree | 76da7c17e1a7e5cce4a06838acdc63ae48789705 | |
| parent | e921861a3d30cfc5f9263747a4e64a68e488288c (diff) | |
| download | man-pages-cbcf76d19f864da8c54e41b600ff5661b195b58e.tar.gz | |
man/man3/strto[u]l.3: BUGS: Signed numbers and white space are not rejected
Link: <https://stackoverflow.com/questions/60955490/strtoul-what-is-the-correct-return-value-for-very-negative-strings>
Reported-by: Bruno Haible <bruno@clisp.org>
Co-authored-by: Bruno Haible <bruno@clisp.org>
Signed-off-by: Bruno Haible <bruno@clisp.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
| -rw-r--r-- | man/man3/strtol.3 | 7 | ||||
| -rw-r--r-- | man/man3/strtoul.3 | 18 |
2 files changed, 20 insertions, 5 deletions
diff --git a/man/man3/strtol.3 b/man/man3/strtol.3 index 9323873a9d..f9c9af4bcb 100644 --- a/man/man3/strtol.3 +++ b/man/man3/strtol.3 @@ -224,6 +224,13 @@ if (errno == EINVAL) goto unsupported_base; .EE .in +.SH BUGS +.SS White space +These functions silently accept leading white space. +To reject white space, call +.BR isspace (3) +before +.BR strtol (). .SH EXAMPLES The program shown below demonstrates the use of .BR strtol (). diff --git a/man/man3/strtoul.3 b/man/man3/strtoul.3 index 9eb260dae4..c4f8961a4d 100644 --- a/man/man3/strtoul.3 +++ b/man/man3/strtoul.3 @@ -204,11 +204,19 @@ to 0 before the call, and then determine if an error occurred by checking whether .I errno has a nonzero value after the call. -.P -Negative values are considered valid input and are -silently converted to the equivalent -.I "unsigned long" -value. +.SH BUGS +.SS Signed numbers +Some negative values +are considered valid input and +are silently converted to +.IR "\%unsigned\ long" . +.SS White space +These functions silently accept leading whitespace. +.SS isalnum(3) +To reject white space and/or a sign, call +.BR isalnum (3) +before +.BR strtoul (). .SH EXAMPLES See the example on the .BR strtol (3) |
