Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.busybox.net/busybox.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2019-09-22 19:26:05 +0300
committerDenys Vlasenko <vda.linux@googlemail.com>2019-10-21 17:54:40 +0300
commit3004510fdc7dfb0c511cfdc0011011bf65a75345 (patch)
treedb0b57dc068e55b21ca8c3b54c80fedd31e3d6fc
parentd6a8784f2790f72b1d147e099f48aeb480b29f1a (diff)
ash: fix BASE##nn bashism to accept letter 'digits' for bases > 9
function old new delta evaluate_string 873 876 +3 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--shell/math.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/shell/math.c b/shell/math.c
index eaf4f2453..0c806ad39 100644
--- a/shell/math.c
+++ b/shell/math.c
@@ -538,9 +538,16 @@ static arith_t strto_arith_t(const char *nptr, char **endptr)
n = 0;
nptr = *endptr + 1;
/* bash allows "N#" (empty "nnnn" part) */
- while (isdigit(*nptr)) {
+ for (;;) {
+ unsigned digit = (unsigned)*nptr - '0';
+ if (digit >= 10 || digit >= base) {
+ digit = (unsigned)(*nptr | 0x20) - ('a' - 10);
+ if (digit >= base)
+ break;
+ }
/* bash does not check for overflows */
- n = n * base + (*nptr++ - '0');
+ n = n * base + digit;
+ nptr++;
}
*endptr = (char*)nptr;
return n;