From: "Pali Rohár" <pali@kernel.org>
To: u-boot@lists.denx.de
Subject: [PATCH] lib: strto: Fix parsing MTD partition size
Date: Fri, 24 Apr 2020 20:21:33 +0200 [thread overview]
Message-ID: <20200424182133.17335-1-pali@kernel.org> (raw)
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
next reply other threads:[~2020-04-24 18:21 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-24 18:21 Pali Rohár [this message]
2020-04-24 18:29 ` [PATCH] lib: strto: Fix parsing MTD partition size 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200424182133.17335-1-pali@kernel.org \
--to=pali@kernel.org \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.