diff options
author | Fyodor Kupolov <fkupolov@google.com> | 2017-02-22 14:12:50 -0800 |
---|---|---|
committer | JP Sugarbroad <jpsugar@google.com> | 2017-03-20 23:08:54 +0000 |
commit | 4996a4b3786d2d8b5f0a726b4ef816d23c4a150b (patch) | |
tree | 62513b66ed44118232423f3819874bce28935ead | |
parent | 9caf6cca41c94e7e590188a4e06ffde75ef1f481 (diff) | |
download | base-4996a4b3786d2d8b5f0a726b4ef816d23c4a150b.tar.gz |
DO NOT MERGE
[DO NOT MERGE] Throw exception if slot has invalid offset
Previously the process would crash, which is OK, but complicates testing.
Test: cts-tradefed run cts --module CtsContentTestCases
--test android.content.cts.ContentProviderCursorWindowTest
Bug: 34128677
Change-Id: I5b50982d77ec65c442fbb973d14c85a5c29c43c7
(cherry picked from commit eb6de6f5f10148b9f81f9c0074d1e1f7af21bfb0)
(cherry picked from commit 3b3f08e68f2d169d0881ef1441102712fff21d1e)
-rw-r--r-- | core/jni/android_database_CursorWindow.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/core/jni/android_database_CursorWindow.cpp b/core/jni/android_database_CursorWindow.cpp index 580ac02789c5..a86e57dc024c 100644 --- a/core/jni/android_database_CursorWindow.cpp +++ b/core/jni/android_database_CursorWindow.cpp @@ -182,6 +182,10 @@ static jbyteArray nativeGetBlob(JNIEnv* env, jclass clazz, jlong windowPtr, if (type == CursorWindow::FIELD_TYPE_BLOB || type == CursorWindow::FIELD_TYPE_STRING) { size_t size; const void* value = window->getFieldSlotValueBlob(fieldSlot, &size); + if (!value) { + throw_sqlite3_exception(env, "Native could not read blob slot"); + return NULL; + } jbyteArray byteArray = env->NewByteArray(size); if (!byteArray) { env->ExceptionClear(); @@ -217,6 +221,10 @@ static jstring nativeGetString(JNIEnv* env, jclass clazz, jlong windowPtr, if (type == CursorWindow::FIELD_TYPE_STRING) { size_t sizeIncludingNull; const char* value = window->getFieldSlotValueString(fieldSlot, &sizeIncludingNull); + if (!value) { + throw_sqlite3_exception(env, "Native could not read string slot"); + return NULL; + } if (sizeIncludingNull <= 1) { return gEmptyString; } |