diff options
author | David Gibson <david@gibson.dropbear.id.au> | 2016-01-12 19:27:25 +1100 |
---|---|---|
committer | David Gibson <david@gibson.dropbear.id.au> | 2016-01-12 19:27:25 +1100 |
commit | b06e55c88b9b922ff7e25cd62a4709b65524f0fc (patch) | |
tree | 9c9914833c50c9c68aac16abd7a8e22c7ad5d633 /dtc-parser.y | |
parent | b43345039b03ac5691961e1ce37dfb8c4c03a863 (diff) | |
download | device-tree-compiler-b06e55c88b9b922ff7e25cd62a4709b65524f0fc.tar.gz |
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@samba.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'dtc-parser.y')
-rw-r--r-- | dtc-parser.y | 10 |
1 files changed, 9 insertions, 1 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 ; |