summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFyodor Kupolov <fkupolov@google.com>2017-02-22 14:12:50 -0800
committergitbuildkicker <android-build@google.com>2017-03-23 16:10:25 -0700
commit4f6d0200bf2f0b3dc7a93ce02bbc88030bcb6ecf (patch)
treebce1ef1f452f999c70e85c4d6a2742c3fb8691d0
parentdaf4e447ac4d6722d028637c8ca46e422e87333d (diff)
downloadbase-4f6d0200bf2f0b3dc7a93ce02bbc88030bcb6ecf.tar.gz
[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 676f703f746391cfdf05bafd2289226f7a6e5255)
-rw-r--r--core/jni/android_database_CursorWindow.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/core/jni/android_database_CursorWindow.cpp b/core/jni/android_database_CursorWindow.cpp
index e96613b7d45b..0d65a1806039 100644
--- a/core/jni/android_database_CursorWindow.cpp
+++ b/core/jni/android_database_CursorWindow.cpp
@@ -205,6 +205,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();
@@ -240,6 +244,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;
}