[Crosstoolchain-logs] [device-tree-compiler] 169/198: Gracefully handle bad octal literals
Hector Oron
zumbi at moszumanska.debian.org
Thu Dec 8 17:07:06 UTC 2016
This is an automated email from the git hooks/post-receive script.
zumbi pushed a commit to branch upstream/1.4.x
in repository device-tree-compiler.
commit 1ab2205a6f0f9e826a623e639da02787d372de37
Author: David Gibson <david at gibson.dropbear.id.au>
Date: Sun Jan 3 22:54:37 2016 +1100
Gracefully handle bad octal literals
The code handling integer literals in dtc-lexer.l assumes that the flex
regexp means that strtoull() can't fail to interpret the string as a valid
integer (either decimal, octal, or hexadecimal). This is not true for
octals. For example '09' is accepted as a literal by the regexp,
strtoull() attempts to handle it as octal, but it has a bad digit.
This changes the code to give a more useful error in this case.
Reported-by: Anton Blanchard <anton at samba.org>
Signed-off-by: David Gibson <david at gibson.dropbear.id.au>
---
dtc-lexer.l | 5 ++++-
tests/bad-octal-literal.dts | 5 +++++
tests/run_tests.sh | 1 +
3 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/dtc-lexer.l b/dtc-lexer.l
index 0ee1caf..22dda7d 100644
--- a/dtc-lexer.l
+++ b/dtc-lexer.l
@@ -153,7 +153,10 @@ static void lexical_error(const char *fmt, ...);
errno = 0;
yylval.integer = strtoull(yytext, &e, 0);
- assert(!(*e) || !e[strspn(e, "UL")]);
+ if (*e && e[strspn(e, "UL")]) {
+ lexical_error("Bad integer literal '%s'",
+ yytext);
+ }
if (errno == ERANGE)
lexical_error("Integer literal '%s' out of range",
diff --git a/tests/bad-octal-literal.dts b/tests/bad-octal-literal.dts
new file mode 100644
index 0000000..26558a2
--- /dev/null
+++ b/tests/bad-octal-literal.dts
@@ -0,0 +1,5 @@
+/dts-v1/;
+
+/ {
+ x = <09>;
+};
diff --git a/tests/run_tests.sh b/tests/run_tests.sh
index 3d6a230..7bdf8e0 100755
--- a/tests/run_tests.sh
+++ b/tests/run_tests.sh
@@ -291,6 +291,7 @@ libfdt_tests () {
run_dtc_test -I dts -O dtb bad-size-cells.dts
run_wrap_error_test $DTC division-by-zero.dts
+ run_wrap_error_test $DTC bad-octal-literal.dts
}
dtc_tests () {
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/crosstoolchain/device-tree-compiler.git
More information about the Crosstoolchain-logs
mailing list