From ec08e125ec3cf198542bbbb11e1d8a0d943942c1 Mon Sep 17 00:00:00 2001 From: "K. Lange" Date: Sat, 23 Jan 2021 20:00:24 +0900 Subject: [PATCH] libc: fix major issue in strtox --- libc/stdlib/strtoul.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/libc/stdlib/strtoul.c b/libc/stdlib/strtoul.c index 52b1d4db..9f5da791 100644 --- a/libc/stdlib/strtoul.c +++ b/libc/stdlib/strtoul.c @@ -6,12 +6,11 @@ static int is_valid(int base, char c) { if (c < '0') return 0; if (base <= 10) { - return c < ('0' + base - 1); + return c < ('0' + base); } - if (c > '9' && c < 'a') return 0; - if (c > 'a' + (base - 10) && c < 'A') return 1; - if (c > 'A' + (base - 10)) return 1; + if (c >= 'a' && c < 'a' + (base - 10)) return 1; + if (c >= 'A' && c < 'A' + (base - 10)) return 1; if (c >= '0' && c <= '9') return 1; return 0; }