summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMichal Simek <michal.simek@xilinx.com>2020-04-08 11:09:16 +0300
committerTom Rini <trini@konsulko.com>2020-04-24 23:40:09 +0300
commit4b4858936fadd61a1696cb5408ab81330ddb5c14 (patch)
treef30fdc1e0170addebff31842edf03bc3d14c1603 /lib
parent593f3976bee1213ac8d3d124c59aefc8889edc8b (diff)
downloadu-boot-4b4858936fadd61a1696cb5408ab81330ddb5c14.tar.xz
lib: strto: Stop detection when invalid char is used
This issue has been found when mtd partition are specified. Autodetection code should stop when the first invalid char is found. Here is the example of commands: setenv mtdids nand0=memory-controller@e000e000 setenv mtdparts "mtdparts=nand0:4m(boot),4m(env),64m(kernel),96m(rootfs)" mtd list Before: Zynq> mtd list List of MTD devices: * nand0 - type: NAND flash - block size: 0x20000 bytes - min I/O: 0x800 bytes - OOB size: 64 bytes - OOB available: 16 bytes - ECC strength: 1 bits - ECC step size: 2048 bytes - bitflip threshold: 1 bits - 0x000000000000-0x000010000000 : "nand0" - 0x000000000000-0x000000400000 : "boot" - 0x000000400000-0x000000800000 : "env" - 0x000000800000-0x000006c00000 : "kernel" - 0x000006c00000-0x000010000000 : "rootfs" Where it is visible that kernel partition has 100m instead of 64m After: Zynq> mtd list * nand0 - type: NAND flash - block size: 0x20000 bytes - min I/O: 0x800 bytes - OOB size: 64 bytes - OOB available: 16 bytes - ECC strength: 1 bits - ECC step size: 2048 bytes - bitflip threshold: 1 bits - 0x000000000000-0x000010000000 : "nand0" - 0x000000000000-0x000000400000 : "boot" - 0x000000400000-0x000000800000 : "env" - 0x000000800000-0x000004800000 : "kernel" - 0x000004800000-0x00000a800000 : "rootfs" Signed-off-by: Michal Simek <michal.simek@xilinx.com> Fixes: 0486497e2b5f ("lib: Improve _parse_integer_fixup_radix base 16 detection") Tested-by: Heiko Schocher <hs@denx.de> Tested-by: Pali Rohár <pali@kernel.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/strto.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/strto.c b/lib/strto.c
index 1ac2b09c72..606701566f 100644
--- a/lib/strto.c
+++ b/lib/strto.c
@@ -34,6 +34,9 @@ static const char *_parse_integer_fixup_radix(const char *s, unsigned int *base)
*base = 16;
break;
}
+
+ if (!(var >= '0' && var <= '9'))
+ break;
} while (var);
}
}