From ab622718f3e2e9f06b324afe5b25b867109cc720 Mon Sep 17 00:00:00 2001 From: Evgenii Stepanov Date: Mon, 3 Oct 2016 14:44:35 -0700 Subject: Fix stack-buffer-overflow detected by AddressSanitizer. Bug: 31855186 Test: boot SANITIZE_TARGET=address build Change-Id: I5c2c64564ccea28e416d66b27af9d86506d622ce --- core/jni/android_hardware_location_ContextHubService.cpp | 5 +++-- 1 file 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 #include +#include #include #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], -- cgit v1.2.3-59-g8ed1b