[Crosstoolchain-logs] [device-tree-compiler] 172/198: Prevent crash on modulo by zero
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 b06e55c88b9b922ff7e25cd62a4709b65524f0fc
Author: David Gibson <david at gibson.dropbear.id.au>
Date: Tue Jan 12 19:27:25 2016 +1100
Prevent crash on modulo by zero
1937095 "Prevent crash on division by zero" fixed a crash when attempting
a division by zero using the / operator in a dts. However, it missed the
precisely equivalent crash with the % (modulus) operator. This patch fixes
the oversight.
Reported-by: Anton Blanchard <anton at samba.org>
Signed-off-by: David Gibson <david at gibson.dropbear.id.au>
---
dtc-parser.y | 10 +++++++++-
tests/division-by-zero.dts | 3 ++-
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/dtc-parser.y b/dtc-parser.y
index 00d4dbb..000873f 100644
--- a/dtc-parser.y
+++ b/dtc-parser.y
@@ -419,7 +419,15 @@ integer_mul:
$$ = 0;
}
}
- | integer_mul '%' integer_unary { $$ = $1 % $3; }
+ | integer_mul '%' integer_unary
+ {
+ if ($3 != 0) {
+ $$ = $1 % $3;
+ } else {
+ ERROR(&@$, "Division by zero");
+ $$ = 0;
+ }
+ }
| integer_unary
;
diff --git a/tests/division-by-zero.dts b/tests/division-by-zero.dts
index d26fc27..2984b29 100644
--- a/tests/division-by-zero.dts
+++ b/tests/division-by-zero.dts
@@ -1,5 +1,6 @@
/dts-v1/;
/ {
- prop = < (1/0) >;
+ prop-div = < (1/0) >;
+ prop-mod = < (1%0) >;
};
--
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