[klibc] [klibc:update-dash] dash: mystring: fix "Illegal number" on FreeBSD & macOS for x=; echo $((x))

klibc-bot for Martijn Dekker martijn at inlv.org
Sat Mar 28 14:48:59 PDT 2020


Commit-ID:  3f6667917c6cc2c90803e1a3e865f2c3b8b1bbf3
Gitweb:     http://git.kernel.org/?p=libs/klibc/klibc.git;a=commit;h=3f6667917c6cc2c90803e1a3e865f2c3b8b1bbf3
Author:     Martijn Dekker <martijn at inlv.org>
AuthorDate: Wed, 7 Mar 2018 13:03:26 +0000
Committer:  Ben Hutchings <ben at decadent.org.uk>
CommitDate: Sat, 28 Mar 2020 21:42:54 +0000

[klibc] dash: mystring: fix "Illegal number" on FreeBSD & macOS for x=; echo $((x))

[ dash commit 2b3fb53c6940471955631353b8bdb7d5a4677fd1 ]

Op 07-03-18 om 06:26 schreef Herbert Xu:
> Martijn Dekker <martijn at inlv.org> wrote:
>>
>>> Since base is always a constant 0 or a constant 10, never a
>>> user-provided value, the only error that strtoimax will ever report on
>>> glibc systems is ERANGE. Checking only ERANGE therefore preserves the
>>> glibc behaviour, and allows the exact same set of errors to be detected
>>> on non-glibc systems.
>>
>> That makes sense, thanks.
>
> Could you resend your patch with this change please?

OK, see below.

- M.

Signed-off-by: Herbert Xu <herbert at gondor.apana.org.au>
Signed-off-by: Ben Hutchings <ben at decadent.org.uk>

---
 usr/dash/mystring.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/usr/dash/mystring.c b/usr/dash/mystring.c
index 0106bd27..de624b89 100644
--- a/usr/dash/mystring.c
+++ b/usr/dash/mystring.c
@@ -125,7 +125,7 @@ intmax_t atomax(const char *s, int base)
 	errno = 0;
 	r = strtoimax(s, &p, base);
 
-	if (errno != 0)
+	if (errno == ERANGE)
 		badnum(s);
 
 	/*


More information about the klibc mailing list