diff options
author | Mallikarjuna Reddy Amireddy <mamire@codeaurora.org> | 2015-10-15 19:42:01 +0530 |
---|---|---|
committer | Steve Kondik <shade@chemlab.org> | 2015-11-04 09:02:49 -0800 |
commit | b956432599de00a5edfeccc56615cb03c229c4e9 (patch) | |
tree | eaad35330803807954a8d70a93c7a950633c597e | |
parent | 3b64a9c67b4e4cbfb90b35210c8c24451998be80 (diff) | |
download | frameworks_base-b956432599de00a5edfeccc56615cb03c229c4e9.zip frameworks_base-b956432599de00a5edfeccc56615cb03c229c4e9.tar.gz frameworks_base-b956432599de00a5edfeccc56615cb03c229c4e9.tar.bz2 |
frameworks/base: fix: string out of boundary.
String length should use GetStringLengh() and the resultant buffer
should be GetStringUTFLength(). So Update the code accordigly to
fix the string out of boundary.
Bug: 921692
Change-Id: I2c3d37ac713b2545e740787bdf1804e15c4c5be6
-rw-r--r-- | core/jni/android_util_SeempLog.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/core/jni/android_util_SeempLog.cpp b/core/jni/android_util_SeempLog.cpp index c45b6ac..734490a 100644 --- a/core/jni/android_util_SeempLog.cpp +++ b/core/jni/android_util_SeempLog.cpp @@ -166,8 +166,8 @@ static jint android_util_SeempLog_println_native(JNIEnv* env, jobject clazz, int apiId = (int)api; int apiIdLen = sizeof(apiId); - int msgLen = env->GetStringUTFLength(msgObj); - int len = apiIdLen + 1 + msgLen + 1; + int utf8MsgLen = env->GetStringUTFLength(msgObj); + int len = apiIdLen + 1 + utf8MsgLen + 1; char *msg = (char*)malloc(len); if ( NULL == msg ) { @@ -177,7 +177,7 @@ static jint android_util_SeempLog_println_native(JNIEnv* env, jobject clazz, *((int*)msg) = apiId; // copy api id // // skip encoding byte - env->GetStringUTFRegion(msgObj, 0, msgLen, params); // copy message + env->GetStringUTFRegion(msgObj, 0, env->GetStringLength(msgObj), params); // copy message msg[len - 1] = 0; // copy terminating zero int res = __android_seemp_socket_write(len, msg); // send message |