diff options
author | Andreas Gampe <agampe@google.com> | 2014-09-25 21:34:25 -0700 |
---|---|---|
committer | Andreas Gampe <agampe@google.com> | 2014-09-25 21:34:25 -0700 |
commit | 2f71cb24fa16c0388591918f1354d1f8608cc6e5 (patch) | |
tree | a34cf37ca643c9af633e8eb32ddacd7a34fce4b2 | |
parent | 5b4a1767f6e4802c99071305e5b69b1ed22ad292 (diff) | |
download | system_core-2f71cb24fa16c0388591918f1354d1f8608cc6e5.zip system_core-2f71cb24fa16c0388591918f1354d1f8608cc6e5.tar.gz system_core-2f71cb24fa16c0388591918f1354d1f8608cc6e5.tar.bz2 |
LibNativeBridge: Fix two bugs
Instruction set comparison must include the termination character
so that prefixes are not identified as equal.
Mount argument order was wrong.
Change-Id: Ib70e36ce2ea5af158ebc9d7fafd00e978348d73d
-rw-r--r-- | libnativebridge/native_bridge.cc | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/libnativebridge/native_bridge.cc b/libnativebridge/native_bridge.cc index 617f776..c19aba9 100644 --- a/libnativebridge/native_bridge.cc +++ b/libnativebridge/native_bridge.cc @@ -205,7 +205,7 @@ static const char* kRuntimeISA = "unknown"; bool NeedsNativeBridge(const char* instruction_set) { - return strncmp(instruction_set, kRuntimeISA, strlen(kRuntimeISA)) != 0; + return strncmp(instruction_set, kRuntimeISA, strlen(kRuntimeISA) + 1) != 0; } #ifdef __APPLE__ @@ -231,7 +231,8 @@ void PreInitializeNativeBridge(const char* app_data_dir_in, const char* instruct // 10 is a loose upper bound on the currently known instruction sets (a tight bound is 7 for // x86_64 [including the trailing \0]). This is so we don't have to change here if there will // be another instruction set in the future. - ALOGW("Instruction set %s is malformed, must be less than 10 characters.", instruction_set); + ALOGW("Instruction set %s is malformed, must be less than or equal to 10 characters.", + instruction_set); return; } @@ -246,7 +247,11 @@ void PreInitializeNativeBridge(const char* app_data_dir_in, const char* instruct "/%s/cpuinfo", instruction_set); // Bind-mount. - if (TEMP_FAILURE_RETRY(mount("/proc/cpuinfo", cpuinfo_path, nullptr, MS_BIND, nullptr)) == -1) { + if (TEMP_FAILURE_RETRY(mount(cpuinfo_path, // Source. + "/proc/cpuinfo", // Target. + nullptr, // FS type. + MS_BIND, // Mount flags: bind mount. + nullptr)) == -1) { // "Data." ALOGW("Failed to bind-mount %s as /proc/cpuinfo: %d", cpuinfo_path, errno); } #else |