diff options
| author | 2021-01-19 19:13:49 +0000 | |
|---|---|---|
| committer | 2021-01-19 19:13:49 +0000 | |
| commit | 57e66d5dd553293803f44544b7cc185aa52e0900 (patch) | |
| tree | bb4f6a042567e86d9c6c9034f249f1505d13919d | |
| parent | 1151863969eaf4e8faaf69fe6d806d624c0af617 (diff) | |
| parent | 41f79e81777799ad2518a603a58cea33698e071a (diff) | |
Merge "HwBlob: explicit size check" am: 4becb19325 am: d35ef5aea8 am: 41f79e8177
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1552564
MUST ONLY BE SUBMITTED BY AUTOMERGER
Change-Id: I7a9a2d1433e1bcd79142e6e5d2ccb993a9efe89b
| -rw-r--r-- | core/jni/android_os_HwBlob.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/core/jni/android_os_HwBlob.cpp b/core/jni/android_os_HwBlob.cpp index 0fb29111d043..a9db91be1d5b 100644 --- a/core/jni/android_os_HwBlob.cpp +++ b/core/jni/android_os_HwBlob.cpp @@ -257,7 +257,17 @@ jobject JHwBlob::NewObject(JNIEnv *env, size_t size) { // XXX Again cannot refer to gFields.constructID because InitClass may // not have been called yet. - return env->NewObject(clazz.get(), constructID, size); + // Cases: + // - this originates from another process (something so large should not fit + // in the binder buffer, and it should be rejected by the binder driver) + // - if this is used in process, this code makes too many heap copies (in + // order to retrofit HIDL's scatter-gather format to java types) to + // justify passing such a large amount of data over this path. So the + // alternative (updating the constructor and other code to accept other + // types, should also probably not be taken in this case). + CHECK_LE(size, std::numeric_limits<jint>::max()); + + return env->NewObject(clazz.get(), constructID, static_cast<jint>(size)); } } // namespace android |