summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Evgenii Stepanov <eugenis@google.com> 2016-10-03 14:44:35 -0700
committer Vishwath Mohan <vishwath@google.com> 2017-01-05 13:03:07 -0800
commitab622718f3e2e9f06b324afe5b25b867109cc720 (patch)
tree65ce293a9385257640d804d049b80a1b50919367
parentc7c899bbe25bdac33dbe42aaefc37d39f28cf714 (diff)
Fix stack-buffer-overflow detected by AddressSanitizer.
Bug: 31855186 Test: boot SANITIZE_TARGET=address build Change-Id: I5c2c64564ccea28e416d66b27af9d86506d622ce
-rw-r--r--core/jni/android_hardware_location_ContextHubService.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/core/jni/android_hardware_location_ContextHubService.cpp b/core/jni/android_hardware_location_ContextHubService.cpp
index 8eb39e1aac58..fbccfd5532e2 100644
--- a/core/jni/android_hardware_location_ContextHubService.cpp
+++ b/core/jni/android_hardware_location_ContextHubService.cpp
@@ -33,6 +33,7 @@
#include <unordered_map>
#include <queue>
+#include <android-base/macros.h>
#include <cutils/log.h>
#include "JNIHelp.h"
@@ -704,10 +705,10 @@ static void passOnOsResponse(uint32_t hubHandle, uint32_t msgType,
}
jbyteArray jmsg = env->NewByteArray(msgLen);
- jintArray jheader = env->NewIntArray(sizeof(header));
+ jintArray jheader = env->NewIntArray(arraysize(header));
env->SetByteArrayRegion(jmsg, 0, msgLen, (jbyte *)msg);
- env->SetIntArrayRegion(jheader, 0, sizeof(header), (jint *)header);
+ env->SetIntArrayRegion(jheader, 0, arraysize(header), (jint *)header);
ALOGI("Passing msg type %" PRIu32 " from app %" PRIu32 " from hub %" PRIu32,
header[HEADER_FIELD_MSG_TYPE], header[HEADER_FIELD_APP_INSTANCE],