OSDN Git Service

Fix benign unsigned overflow
authorChad Brubaker <cbrubaker@google.com>
Wed, 12 Aug 2015 19:46:44 +0000 (12:46 -0700)
committerChad Brubaker <cbrubaker@google.com>
Wed, 12 Aug 2015 19:46:44 +0000 (12:46 -0700)
On the last check of the conditional param_count-- causes an unsigned
wrap around. This isn't incorrect but does lead to a false positive with
fsanitize unsigned-integer-overflow

Change-Id: If3eb7a9e248d0404a434de2ead70e8c099e84ddf

include/hardware/keymaster_defs.h

index 5be956d..73d95d0 100644 (file)
@@ -481,7 +481,8 @@ inline int keymaster_param_compare(const keymaster_key_param_t* a, const keymast
 #undef KEYMASTER_SIMPLE_COMPARE
 
 inline void keymaster_free_param_values(keymaster_key_param_t* param, size_t param_count) {
-    while (param_count-- > 0) {
+    while (param_count > 0) {
+        param_count--;
         switch (keymaster_tag_get_type(param->tag)) {
         case KM_BIGNUM:
         case KM_BYTES: