Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1249)

Unified Diff: content/public/android/java/src/org/chromium/content/app/LibraryLoader.java

Issue 59533009: Check library version and handle library load errors (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/public/android/java/src/org/chromium/content/app/LibraryLoader.java
diff --git a/content/public/android/java/src/org/chromium/content/app/LibraryLoader.java b/content/public/android/java/src/org/chromium/content/app/LibraryLoader.java
index 8883255ca4d10707c22872202df91b0a63e6659e..07f4835e51ded1221f637890ba496c4f7afad866 100644
--- a/content/public/android/java/src/org/chromium/content/app/LibraryLoader.java
+++ b/content/public/android/java/src/org/chromium/content/app/LibraryLoader.java
@@ -135,6 +135,11 @@ public class LibraryLoader {
} catch (UnsatisfiedLinkError e) {
throw new ProcessInitException(ResultCodes.RESULT_CODE_NATIVE_LIBRARY_LOAD_FAILED, e);
}
+ // Check that the version of the library we have loaded matches the version we expect
+ if(! NativeLibraries.VersionName.equals(nativeGetVersionName()) ) {
+ throw new ProcessInitException(ResultCodes.RESULT_CODE_NATIVE_LIBRARY_WRONG_VERSION);
+ }
+
}
@@ -157,13 +162,13 @@ public class LibraryLoader {
TraceEvent.setEnabledToMatchNative();
// Record histogram for the content linker.
if (Linker.isUsed())
- nativeRecordContentAndroidLinkerHistogram(Linker.loadAtFixedAddressFailed(),
+ nativeRecordContentAndroidLinkerHistogram(Linker.loadAtFixedAddressFailed(),
SysUtils.isLowEndDevice());
}
- // This is the only method that is registered during System.loadLibrary. We then call it
- // to register everything else. This process is called "initialization".
- // This method will be mapped (by generated code) to the LibraryLoaded
+ // Only methods needed before or during normal JNI registration are during System.OnLoad.
+ // nativeLibraryLoaded is then called to register everything else. This process is called
+ // "initialization". This method will be mapped (by generated code) to the LibraryLoaded
// definition in content/app/android/library_loader_hooks.cc.
//
// Return 0 on success, otherwise return the error code from
@@ -176,4 +181,8 @@ public class LibraryLoader {
private static native void nativeRecordContentAndroidLinkerHistogram(
boolean loadedAtFixedAddressFailed,
boolean isLowMemoryDevice);
+
+ // Get the version of the native library. This is needed so that we can check we
+ // have the right version before initializing the (rest of the) JNI.
+ private static native String nativeGetVersionName();
}

Powered by Google App Engine
This is Rietveld 408576698