public inbox for linux-man@vger.kernel.org
 help / color / mirror / Atom feed
From: Alejandro Colomar <alx@kernel.org>
To: linux-man@vger.kernel.org, Bruno Haible <bruno@clisp.org>
Cc: Alejandro Colomar <alx@kernel.org>
Subject: [PATCH v4 1/2] man/man3/strto[u]l.3: BUGS: Signed numbers and white space are not rejected
Date: Sun, 23 Mar 2025 12:43:10 +0100	[thread overview]
Message-ID: <4a1de398dce8303ce6a3d729f8afcf73fb487e5f.1742730109.git.alx@kernel.org> (raw)
In-Reply-To: <cover.1742730109.git.alx@kernel.org>

[-- Attachment #1: Type: text/plain, Size: 1662 bytes --]

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: Alejandro Colomar <alx@kernel.org>
---
 man/man3/strtol.3  |  7 +++++++
 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 9323873a9..f9c9af4bc 100644
--- a/man/man3/strtol.3
+++ b/man/man3/strtol.3
@@ -224,6 +224,13 @@ .SH CAVEATS
     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 9eb260dae..c4f8961a4 100644
--- a/man/man3/strtoul.3
+++ b/man/man3/strtoul.3
@@ -204,11 +204,19 @@ .SH CAVEATS
 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)
-- 
2.47.2


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2025-03-23 11:43 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-21 20:41 [PATCH v1] man/man3/strtoul.3: BUGS: Signed numbers are not rejected Alejandro Colomar
2025-03-21 21:31 ` Bruno Haible
2025-03-21 22:21   ` Alejandro Colomar
2025-03-21 22:18 ` [PATCH v2 0/2] strto[u]l(3) BUGS and CAVEATS Alejandro Colomar
2025-03-21 22:18   ` [PATCH v2 1/2] man/man3/strto[u]l.3: BUGS: Signed numbers and white space are not rejected Alejandro Colomar
2025-03-21 22:18   ` [PATCH v2 2/2] man/man3/strtol.3: CAVEATS: Clarify how to perform range checks Alejandro Colomar
2025-03-23  0:30 ` [PATCH v3 0/2] strto[u]l.3: BUGS and CAVEATS Alejandro Colomar
2025-03-23  0:30   ` [PATCH v3 1/2] man/man3/strto[u]l.3: BUGS: Signed numbers and white space are not rejected Alejandro Colomar
2025-03-23 10:27     ` Bruno Haible
2025-03-23 11:15       ` Alejandro Colomar
2025-03-23  0:30   ` [PATCH v3 2/2] man/man3/strtol.3: CAVEATS: Clarify how to perform range checks Alejandro Colomar
2025-03-23 11:43 ` [PATCH v4 0/2] strto[u]l.3: BUGS and CAVEATS Alejandro Colomar
2025-03-23 11:43   ` Alejandro Colomar [this message]
2025-03-23 13:20     ` [PATCH v4 1/2] man/man3/strto[u]l.3: BUGS: Signed numbers and white space are not rejected Bruno Haible
2025-03-23 14:00       ` Alejandro Colomar
2025-03-23 15:52         ` Bruno Haible
2025-03-23 16:55           ` Alejandro Colomar
2025-03-23 17:03             ` Alejandro Colomar
2025-03-23 17:11               ` Bruno Haible
2025-03-23 18:35                 ` Alejandro Colomar
2025-03-23 18:55           ` Alejandro Colomar
2025-03-23 19:26             ` Bruno Haible
2025-03-23 19:47               ` Alejandro Colomar
2025-03-23 11:43   ` [PATCH v4 2/2] man/man3/strtol.3: CAVEATS: Clarify how to perform range checks Alejandro Colomar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4a1de398dce8303ce6a3d729f8afcf73fb487e5f.1742730109.git.alx@kernel.org \
    --to=alx@kernel.org \
    --cc=bruno@clisp.org \
    --cc=linux-man@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox