summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorJeff Brown <jeffbrown@google.com>2012-04-19 19:44:43 -0700
committerJeff Brown <jeffbrown@google.com>2012-04-19 19:44:43 -0700
commit330ec91e02406ba0d62e5672c6f0e2ed271f6898 (patch)
tree6af388cfe3833115638a38e2aec2452f9a965529 /core
parent59a422e90035ce5df45c526607db2d3303e3112e (diff)
downloadframeworks_base-330ec91e02406ba0d62e5672c6f0e2ed271f6898.zip
frameworks_base-330ec91e02406ba0d62e5672c6f0e2ed271f6898.tar.gz
frameworks_base-330ec91e02406ba0d62e5672c6f0e2ed271f6898.tar.bz2
Check whether db was really opened read/write.
Bug: 6176510 Change-Id: I7aeeb4340e55d554a57bb46c3c27ab37186f7e3a
Diffstat (limited to 'core')
-rw-r--r--core/jni/android_database_SQLiteConnection.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/core/jni/android_database_SQLiteConnection.cpp b/core/jni/android_database_SQLiteConnection.cpp
index fca5f20..0777ea2 100644
--- a/core/jni/android_database_SQLiteConnection.cpp
+++ b/core/jni/android_database_SQLiteConnection.cpp
@@ -120,6 +120,13 @@ static jint nativeOpen(JNIEnv* env, jclass clazz, jstring pathStr, jint openFlag
return 0;
}
+ // Check that the database is really read/write when that is what we asked for.
+ if ((sqliteFlags & SQLITE_OPEN_READWRITE) && sqlite3_db_readonly(db, NULL)) {
+ throw_sqlite3_exception(env, db, "Could not open the database in read/write mode.");
+ sqlite3_close(db);
+ return 0;
+ }
+
// Set the default busy handler to retry for 1000ms and then return SQLITE_BUSY
err = sqlite3_busy_timeout(db, 1000 /* ms */);
if (err != SQLITE_OK) {