Fix overflow check in shift right expression
The check needs to be inclusive. It was missing cases where the shift
exponent was the same size as the number of bits in the type.
Fixes: 169627378
Test: aidl_parser_fuzzer test/corpus/shift_right_64
Change-Id: Ie796490b08009bef3c51d5470b8d4490275a173a
diff --git a/aidl_const_expressions.cpp b/aidl_const_expressions.cpp
index cb5566b..a4e26e0 100644
--- a/aidl_const_expressions.cpp
+++ b/aidl_const_expressions.cpp
@@ -106,7 +106,7 @@
T operator==(T o) { return mValue == o; }
T operator!=(T o) { return mValue != o; }
T operator>>(T o) {
- if (o < 0 || o > static_cast<T>(sizeof(T) * 8) || mValue < 0) {
+ if (o < 0 || o >= static_cast<T>(sizeof(T) * 8) || mValue < 0) {
mOverflowed = true;
return 0;
}