All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] lib: strto: Fix parsing MTD partition size
@ 2020-04-24 18:21 Pali Rohár
  2020-04-24 18:29 ` Pali Rohár
  0 siblings, 1 reply; 7+ messages in thread
From: Pali Rohár @ 2020-04-24 18:21 UTC (permalink / raw)
  To: u-boot

Commit 0486497e2b5f ("lib: Improve _parse_integer_fixup_radix base 16
detection") broke parsing MTD partition sizes specified in decimal base.

E.g. "128k(bootloader)" is parsed by drivers/mtd/mtdpart.c as hexadecimal
number (0x128 << 10) because character 'a' in substring "bootloader" caused
parsing whole number as hexadecimal.

This patch stop doing hexadecimal base heuristic on first non-valid
hexadecimal number, so "128k(bootloader)" is parsed as decimal number 128.

Fixes: 0486497e2b5f ("lib: Improve _parse_integer_fixup_radix base 16...")
Signed-off-by: Pali Roh?r <pali@kernel.org>
---
 lib/strto.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lib/strto.c b/lib/strto.c
index 1ac2b09c72..060b66b915 100644
--- a/lib/strto.c
+++ b/lib/strto.c
@@ -30,6 +30,9 @@ static const char *_parse_integer_fixup_radix(const char *s, unsigned int *base)
 
 			do {
 				var = tolower(s[i++]);
+				if (!(var >= '0' && var <= '9') &&
+				    !(var >= 'a' && var <= 'f'))
+					break;
 				if (var >= 'a' && var <= 'f') {
 					*base = 16;
 					break;
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH] lib: strto: Fix parsing MTD partition size
  2020-04-24 18:21 [PATCH] lib: strto: Fix parsing MTD partition size Pali Rohár
@ 2020-04-24 18:29 ` Pali Rohár
  2020-04-24 19:12   ` Tom Rini
  0 siblings, 1 reply; 7+ messages in thread
From: Pali Rohár @ 2020-04-24 18:29 UTC (permalink / raw)
  To: u-boot

On Friday 24 April 2020 20:21:33 Pali Roh?r wrote:
> Commit 0486497e2b5f ("lib: Improve _parse_integer_fixup_radix base 16
> detection") broke parsing MTD partition sizes specified in decimal base.
> 
> E.g. "128k(bootloader)" is parsed by drivers/mtd/mtdpart.c as hexadecimal
> number (0x128 << 10) because character 'a' in substring "bootloader" caused
> parsing whole number as hexadecimal.
> 
> This patch stop doing hexadecimal base heuristic on first non-valid
> hexadecimal number, so "128k(bootloader)" is parsed as decimal number 128.
> 
> Fixes: 0486497e2b5f ("lib: Improve _parse_integer_fixup_radix base 16...")
> Signed-off-by: Pali Roh?r <pali@kernel.org>
> ---
>  lib/strto.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/lib/strto.c b/lib/strto.c
> index 1ac2b09c72..060b66b915 100644
> --- a/lib/strto.c
> +++ b/lib/strto.c
> @@ -30,6 +30,9 @@ static const char *_parse_integer_fixup_radix(const char *s, unsigned int *base)
>  
>  			do {
>  				var = tolower(s[i++]);
> +				if (!(var >= '0' && var <= '9') &&
> +				    !(var >= 'a' && var <= 'f'))
> +					break;
>  				if (var >= 'a' && var <= 'f') {
>  					*base = 16;
>  					break;
> -- 
> 2.20.1
> 

CC Tom, this problem was detected by my in-progress Travis Nokia N900
test which tries to boot kernel from the OneNAND. Build log is there:
https://travis-ci.org/github/u-boot/u-boot/jobs/679007310

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH] lib: strto: Fix parsing MTD partition size
  2020-04-24 18:29 ` Pali Rohár
@ 2020-04-24 19:12   ` Tom Rini
  2020-04-24 19:15     ` Pali Rohár
  0 siblings, 1 reply; 7+ messages in thread
From: Tom Rini @ 2020-04-24 19:12 UTC (permalink / raw)
  To: u-boot

On Fri, Apr 24, 2020 at 08:29:41PM +0200, Pali Roh?r wrote:
> On Friday 24 April 2020 20:21:33 Pali Roh?r wrote:
> > Commit 0486497e2b5f ("lib: Improve _parse_integer_fixup_radix base 16
> > detection") broke parsing MTD partition sizes specified in decimal base.
> > 
> > E.g. "128k(bootloader)" is parsed by drivers/mtd/mtdpart.c as hexadecimal
> > number (0x128 << 10) because character 'a' in substring "bootloader" caused
> > parsing whole number as hexadecimal.
> > 
> > This patch stop doing hexadecimal base heuristic on first non-valid
> > hexadecimal number, so "128k(bootloader)" is parsed as decimal number 128.
> > 
> > Fixes: 0486497e2b5f ("lib: Improve _parse_integer_fixup_radix base 16...")
> > Signed-off-by: Pali Roh?r <pali@kernel.org>
> > ---
> >  lib/strto.c | 3 +++
> >  1 file changed, 3 insertions(+)
> > 
> > diff --git a/lib/strto.c b/lib/strto.c
> > index 1ac2b09c72..060b66b915 100644
> > --- a/lib/strto.c
> > +++ b/lib/strto.c
> > @@ -30,6 +30,9 @@ static const char *_parse_integer_fixup_radix(const char *s, unsigned int *base)
> >  
> >  			do {
> >  				var = tolower(s[i++]);
> > +				if (!(var >= '0' && var <= '9') &&
> > +				    !(var >= 'a' && var <= 'f'))
> > +					break;
> >  				if (var >= 'a' && var <= 'f') {
> >  					*base = 16;
> >  					break;
> > -- 
> > 2.20.1
> > 
> 
> CC Tom, this problem was detected by my in-progress Travis Nokia N900
> test which tries to boot kernel from the OneNAND. Build log is there:
> https://travis-ci.org/github/u-boot/u-boot/jobs/679007310

This is the same as:
http://patchwork.ozlabs.org/project/uboot/patch/1a681dbefac4c353ad53d7f6cd1a75812036739a.1586333353.git.michal.simek at xilinx.com/
yes?  Thanks!

-- 
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/20200424/8606d572/attachment.sig>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH] lib: strto: Fix parsing MTD partition size
  2020-04-24 19:12   ` Tom Rini
@ 2020-04-24 19:15     ` Pali Rohár
  2020-04-24 19:28       ` Tom Rini
  0 siblings, 1 reply; 7+ messages in thread
From: Pali Rohár @ 2020-04-24 19:15 UTC (permalink / raw)
  To: u-boot

On Friday 24 April 2020 15:12:42 Tom Rini wrote:
> On Fri, Apr 24, 2020 at 08:29:41PM +0200, Pali Roh?r wrote:
> > On Friday 24 April 2020 20:21:33 Pali Roh?r wrote:
> > > Commit 0486497e2b5f ("lib: Improve _parse_integer_fixup_radix base 16
> > > detection") broke parsing MTD partition sizes specified in decimal base.
> > > 
> > > E.g. "128k(bootloader)" is parsed by drivers/mtd/mtdpart.c as hexadecimal
> > > number (0x128 << 10) because character 'a' in substring "bootloader" caused
> > > parsing whole number as hexadecimal.
> > > 
> > > This patch stop doing hexadecimal base heuristic on first non-valid
> > > hexadecimal number, so "128k(bootloader)" is parsed as decimal number 128.
> > > 
> > > Fixes: 0486497e2b5f ("lib: Improve _parse_integer_fixup_radix base 16...")
> > > Signed-off-by: Pali Roh?r <pali@kernel.org>
> > > ---
> > >  lib/strto.c | 3 +++
> > >  1 file changed, 3 insertions(+)
> > > 
> > > diff --git a/lib/strto.c b/lib/strto.c
> > > index 1ac2b09c72..060b66b915 100644
> > > --- a/lib/strto.c
> > > +++ b/lib/strto.c
> > > @@ -30,6 +30,9 @@ static const char *_parse_integer_fixup_radix(const char *s, unsigned int *base)
> > >  
> > >  			do {
> > >  				var = tolower(s[i++]);
> > > +				if (!(var >= '0' && var <= '9') &&
> > > +				    !(var >= 'a' && var <= 'f'))
> > > +					break;
> > >  				if (var >= 'a' && var <= 'f') {
> > >  					*base = 16;
> > >  					break;
> > > -- 
> > > 2.20.1
> > > 
> > 
> > CC Tom, this problem was detected by my in-progress Travis Nokia N900
> > test which tries to boot kernel from the OneNAND. Build log is there:
> > https://travis-ci.org/github/u-boot/u-boot/jobs/679007310
> 
> This is the same as:
> http://patchwork.ozlabs.org/project/uboot/patch/1a681dbefac4c353ad53d7f6cd1a75812036739a.1586333353.git.michal.simek at xilinx.com/
> yes?  Thanks!

Yes, this is the same problem.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH] lib: strto: Fix parsing MTD partition size
  2020-04-24 19:15     ` Pali Rohár
@ 2020-04-24 19:28       ` Tom Rini
  2020-04-24 19:33         ` Pali Rohár
  0 siblings, 1 reply; 7+ messages in thread
From: Tom Rini @ 2020-04-24 19:28 UTC (permalink / raw)
  To: u-boot

On Fri, Apr 24, 2020 at 09:15:43PM +0200, Pali Roh?r wrote:
> On Friday 24 April 2020 15:12:42 Tom Rini wrote:
> > On Fri, Apr 24, 2020 at 08:29:41PM +0200, Pali Roh?r wrote:
> > > On Friday 24 April 2020 20:21:33 Pali Roh?r wrote:
> > > > Commit 0486497e2b5f ("lib: Improve _parse_integer_fixup_radix base 16
> > > > detection") broke parsing MTD partition sizes specified in decimal base.
> > > > 
> > > > E.g. "128k(bootloader)" is parsed by drivers/mtd/mtdpart.c as hexadecimal
> > > > number (0x128 << 10) because character 'a' in substring "bootloader" caused
> > > > parsing whole number as hexadecimal.
> > > > 
> > > > This patch stop doing hexadecimal base heuristic on first non-valid
> > > > hexadecimal number, so "128k(bootloader)" is parsed as decimal number 128.
> > > > 
> > > > Fixes: 0486497e2b5f ("lib: Improve _parse_integer_fixup_radix base 16...")
> > > > Signed-off-by: Pali Roh?r <pali@kernel.org>
> > > > ---
> > > >  lib/strto.c | 3 +++
> > > >  1 file changed, 3 insertions(+)
> > > > 
> > > > diff --git a/lib/strto.c b/lib/strto.c
> > > > index 1ac2b09c72..060b66b915 100644
> > > > --- a/lib/strto.c
> > > > +++ b/lib/strto.c
> > > > @@ -30,6 +30,9 @@ static const char *_parse_integer_fixup_radix(const char *s, unsigned int *base)
> > > >  
> > > >  			do {
> > > >  				var = tolower(s[i++]);
> > > > +				if (!(var >= '0' && var <= '9') &&
> > > > +				    !(var >= 'a' && var <= 'f'))
> > > > +					break;
> > > >  				if (var >= 'a' && var <= 'f') {
> > > >  					*base = 16;
> > > >  					break;
> > > > -- 
> > > > 2.20.1
> > > > 
> > > 
> > > CC Tom, this problem was detected by my in-progress Travis Nokia N900
> > > test which tries to boot kernel from the OneNAND. Build log is there:
> > > https://travis-ci.org/github/u-boot/u-boot/jobs/679007310
> > 
> > This is the same as:
> > http://patchwork.ozlabs.org/project/uboot/patch/1a681dbefac4c353ad53d7f6cd1a75812036739a.1586333353.git.michal.simek at xilinx.com/
> > yes?  Thanks!
> 
> Yes, this is the same problem.

Can you please test (and Tested-by) that one?  Thanks!

-- 
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/20200424/e537a697/attachment.sig>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH] lib: strto: Fix parsing MTD partition size
  2020-04-24 19:28       ` Tom Rini
@ 2020-04-24 19:33         ` Pali Rohár
  2020-04-24 19:40           ` Pali Rohár
  0 siblings, 1 reply; 7+ messages in thread
From: Pali Rohár @ 2020-04-24 19:33 UTC (permalink / raw)
  To: u-boot

On Friday 24 April 2020 15:28:01 Tom Rini wrote:
> On Fri, Apr 24, 2020 at 09:15:43PM +0200, Pali Roh?r wrote:
> > On Friday 24 April 2020 15:12:42 Tom Rini wrote:
> > > On Fri, Apr 24, 2020 at 08:29:41PM +0200, Pali Roh?r wrote:
> > > > On Friday 24 April 2020 20:21:33 Pali Roh?r wrote:
> > > > > Commit 0486497e2b5f ("lib: Improve _parse_integer_fixup_radix base 16
> > > > > detection") broke parsing MTD partition sizes specified in decimal base.
> > > > > 
> > > > > E.g. "128k(bootloader)" is parsed by drivers/mtd/mtdpart.c as hexadecimal
> > > > > number (0x128 << 10) because character 'a' in substring "bootloader" caused
> > > > > parsing whole number as hexadecimal.
> > > > > 
> > > > > This patch stop doing hexadecimal base heuristic on first non-valid
> > > > > hexadecimal number, so "128k(bootloader)" is parsed as decimal number 128.
> > > > > 
> > > > > Fixes: 0486497e2b5f ("lib: Improve _parse_integer_fixup_radix base 16...")
> > > > > Signed-off-by: Pali Roh?r <pali@kernel.org>
> > > > > ---
> > > > >  lib/strto.c | 3 +++
> > > > >  1 file changed, 3 insertions(+)
> > > > > 
> > > > > diff --git a/lib/strto.c b/lib/strto.c
> > > > > index 1ac2b09c72..060b66b915 100644
> > > > > --- a/lib/strto.c
> > > > > +++ b/lib/strto.c
> > > > > @@ -30,6 +30,9 @@ static const char *_parse_integer_fixup_radix(const char *s, unsigned int *base)
> > > > >  
> > > > >  			do {
> > > > >  				var = tolower(s[i++]);
> > > > > +				if (!(var >= '0' && var <= '9') &&
> > > > > +				    !(var >= 'a' && var <= 'f'))
> > > > > +					break;
> > > > >  				if (var >= 'a' && var <= 'f') {
> > > > >  					*base = 16;
> > > > >  					break;
> > > > > -- 
> > > > > 2.20.1
> > > > > 
> > > > 
> > > > CC Tom, this problem was detected by my in-progress Travis Nokia N900
> > > > test which tries to boot kernel from the OneNAND. Build log is there:
> > > > https://travis-ci.org/github/u-boot/u-boot/jobs/679007310
> > > 
> > > This is the same as:
> > > http://patchwork.ozlabs.org/project/uboot/patch/1a681dbefac4c353ad53d7f6cd1a75812036739a.1586333353.git.michal.simek at xilinx.com/
> > > yes?  Thanks!
> > 
> > Yes, this is the same problem.
> 
> Can you please test (and Tested-by) that one?  Thanks!

It is basically same patch as mine... but ok I'm going to run that my
automated Nokia N900 test locally with above patch.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH] lib: strto: Fix parsing MTD partition size
  2020-04-24 19:33         ` Pali Rohár
@ 2020-04-24 19:40           ` Pali Rohár
  0 siblings, 0 replies; 7+ messages in thread
From: Pali Rohár @ 2020-04-24 19:40 UTC (permalink / raw)
  To: u-boot

On Friday 24 April 2020 21:33:42 Pali Roh?r wrote:
> On Friday 24 April 2020 15:28:01 Tom Rini wrote:
> > On Fri, Apr 24, 2020 at 09:15:43PM +0200, Pali Roh?r wrote:
> > > On Friday 24 April 2020 15:12:42 Tom Rini wrote:
> > > > On Fri, Apr 24, 2020 at 08:29:41PM +0200, Pali Roh?r wrote:
> > > > > On Friday 24 April 2020 20:21:33 Pali Roh?r wrote:
> > > > > > Commit 0486497e2b5f ("lib: Improve _parse_integer_fixup_radix base 16
> > > > > > detection") broke parsing MTD partition sizes specified in decimal base.
> > > > > > 
> > > > > > E.g. "128k(bootloader)" is parsed by drivers/mtd/mtdpart.c as hexadecimal
> > > > > > number (0x128 << 10) because character 'a' in substring "bootloader" caused
> > > > > > parsing whole number as hexadecimal.
> > > > > > 
> > > > > > This patch stop doing hexadecimal base heuristic on first non-valid
> > > > > > hexadecimal number, so "128k(bootloader)" is parsed as decimal number 128.
> > > > > > 
> > > > > > Fixes: 0486497e2b5f ("lib: Improve _parse_integer_fixup_radix base 16...")
> > > > > > Signed-off-by: Pali Roh?r <pali@kernel.org>
> > > > > > ---
> > > > > >  lib/strto.c | 3 +++
> > > > > >  1 file changed, 3 insertions(+)
> > > > > > 
> > > > > > diff --git a/lib/strto.c b/lib/strto.c
> > > > > > index 1ac2b09c72..060b66b915 100644
> > > > > > --- a/lib/strto.c
> > > > > > +++ b/lib/strto.c
> > > > > > @@ -30,6 +30,9 @@ static const char *_parse_integer_fixup_radix(const char *s, unsigned int *base)
> > > > > >  
> > > > > >  			do {
> > > > > >  				var = tolower(s[i++]);
> > > > > > +				if (!(var >= '0' && var <= '9') &&
> > > > > > +				    !(var >= 'a' && var <= 'f'))
> > > > > > +					break;
> > > > > >  				if (var >= 'a' && var <= 'f') {
> > > > > >  					*base = 16;
> > > > > >  					break;
> > > > > > -- 
> > > > > > 2.20.1
> > > > > > 
> > > > > 
> > > > > CC Tom, this problem was detected by my in-progress Travis Nokia N900
> > > > > test which tries to boot kernel from the OneNAND. Build log is there:
> > > > > https://travis-ci.org/github/u-boot/u-boot/jobs/679007310
> > > > 
> > > > This is the same as:
> > > > http://patchwork.ozlabs.org/project/uboot/patch/1a681dbefac4c353ad53d7f6cd1a75812036739a.1586333353.git.michal.simek at xilinx.com/
> > > > yes?  Thanks!
> > > 
> > > Yes, this is the same problem.
> > 
> > Can you please test (and Tested-by) that one?  Thanks!
> 
> It is basically same patch as mine... but ok I'm going to run that my
> automated Nokia N900 test locally with above patch.

That patch is working fine, you can add my Tested-by: Pali Roh?r <pali@kernel.org> for it

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-04-24 19:40 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-04-24 18:21 [PATCH] lib: strto: Fix parsing MTD partition size Pali Rohár
2020-04-24 18:29 ` Pali Rohár
2020-04-24 19:12   ` Tom Rini
2020-04-24 19:15     ` Pali Rohár
2020-04-24 19:28       ` Tom Rini
2020-04-24 19:33         ` Pali Rohár
2020-04-24 19:40           ` Pali Rohár

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.