lib: strto: Stop detection when invalid char is used
PATCH 1/1 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 at 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"
---
lib/strto.c | 3 +++ 1 file changed, 3 insertions(+)
lib/strto.c +3 -0
@@ -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); } }
Signature · 1 line
2.26.0
PATCH 1/1 lib: strto: Stop detection when invalid char is used
Hello Michal,
Am 08.04.2020 um 10:09 schrieb Michal Simek:
Quoted 57 lines
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 ate000e000
setenv mtdparts "mtdparts=nand0:4m(boot),4m(env),64m(kernel),96m(rootfs)" mtd listBefore:
Zynq> mtd list
List of MTD devices:
* nand0
- type: NAND flash
- block size:0x20000bytes
- min I/O:0x800bytes
- 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:0x20000bytes
- min I/O:0x800bytes
- 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 <[email protected]>---
lib/strto.c | 3 +++ 1 file changed, 3 insertions(+)lib/strto.c +0
-0
lib/strto.c static const char *_parse_integer_fixup_radix(const char *s, unsigned int *base) · line 42
Quoted 9 lines
lib/strto.c +3
-0@@ -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); } }
Fixes for me same problem, detected on imx6ull based board, thanks!
for the records:
mtdparts before this patch:
=> mtdparts
device nand0 <gpmi-nand>, # parts = 1
#: name size offset mask_flags 0: ubi 0x10000000 0x00000000 0
device nor0 <spi1.0>, # parts = 6
#: name size offset mask_flags 0: spl 0x00019000 0x00000000 0 1: u-boot 0x001da000 0x00019000 0 2: env 0x00019000 0x001f3000 0 3: env-red 0x00019000 0x0020c000 0 4: key 0x00019000 0x00225000 0 5: rescue 0x00dc2000 0x0023e000 0
active partition: nand0,0 - (ubi) 0x10000000 @ 0x00000000
defaults:
mtdids : nand0=gpmi-nand,nor0=spi1.0
mtdparts:
mtdparts=gpmi-nand:-(ubi);spi1.0:64k(spl),768k(u-boot),64k(env),64k(env-red),64k(key),-(rescue) =>
after
=> mtdparts
device nand0 <gpmi-nand>, # parts = 1
#: name size offset mask_flags 0: ubi 0x10000000 0x00000000 0
device nor0 <spi1.0>, # parts = 6
#: name size offset mask_flags 0: spl 0x00010000 0x00000000 0 1: u-boot 0x000c0000 0x00010000 0 2: env 0x00010000 0x000d0000 0 3: env-red 0x00010000 0x000e0000 0 4: key 0x00010000 0x000f0000 0 5: rescue 0x00f00000 0x00100000 0
active partition: nand0,0 - (ubi) 0x10000000 @ 0x00000000
defaults:
mtdids : nand0=gpmi-nand,nor0=spi1.0
mtdparts:
mtdparts=gpmi-nand:-(ubi);spi1.0:64k(spl),768k(u-boot),64k(env),64k(env-red),64k(key),-(rescue) =>
bye,
Heiko
Signature · 3 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-52 Fax: +49-8142-66989-80 Email: hs at denx.de
PATCH 1/1 lib: strto: Stop detection when invalid char is used
In reply to Michal SimekQuoted 45 lines · Michal Simek
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 ate000e000
setenv mtdparts "mtdparts=nand0:4m(boot),4m(env),64m(kernel),96m(rootfs)" mtd listBefore:
Zynq> mtd list
List of MTD devices:
* nand0
- type: NAND flash
- block size:0x20000bytes
- min I/O:0x800bytes
- 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:0x20000bytes
- min I/O:0x800bytes
- 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"
Quoted 2 lines
Signed-off-by Michal Simek <[email protected]>Tested-by Heiko Schocher <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200426/68b84333/attachment.sig>