summaryrefslogtreecommitdiffstats
path: root/media/libstagefright/include/SoftOMXComponent.h
diff options
context:
space:
mode:
authorMarco Nelissen <marcone@google.com>2016-02-29 12:47:20 -0800
committerThe Android Automerger <android-build@google.com>2016-04-21 19:09:54 -0700
commit295c883fe3105b19bcd0f9e07d54c6b589fc5bff (patch)
tree78e44d1f67000b06f9a621b01e11bb0fa647c59b /media/libstagefright/include/SoftOMXComponent.h
parentdaa85dac2055b22dabbb3b4e537597e6ab73a866 (diff)
downloadframeworks_av-295c883fe3105b19bcd0f9e07d54c6b589fc5bff.zip
frameworks_av-295c883fe3105b19bcd0f9e07d54c6b589fc5bff.tar.gz
frameworks_av-295c883fe3105b19bcd0f9e07d54c6b589fc5bff.tar.bz2
DO NOT MERGE Verify OMX buffer sizes prior to access
Bug: 27207275 Change-Id: I4412825d1ee233d993af0a67708bea54304ff62d
Diffstat (limited to 'media/libstagefright/include/SoftOMXComponent.h')
-rw-r--r--media/libstagefright/include/SoftOMXComponent.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/media/libstagefright/include/SoftOMXComponent.h b/media/libstagefright/include/SoftOMXComponent.h
index a808611..3ab6f88 100644
--- a/media/libstagefright/include/SoftOMXComponent.h
+++ b/media/libstagefright/include/SoftOMXComponent.h
@@ -168,6 +168,22 @@ private:
DISALLOW_EVIL_CONSTRUCTORS(SoftOMXComponent);
};
+template<typename T>
+bool isValidOMXParam(T *a) {
+ static_assert(offsetof(typeof(*a), nSize) == 0, "nSize not at offset 0");
+ static_assert(std::is_same< decltype(a->nSize), OMX_U32>::value, "nSize has wrong type");
+ static_assert(offsetof(typeof(*a), nVersion) == 4, "nVersion not at offset 4");
+ static_assert(std::is_same< decltype(a->nVersion), OMX_VERSIONTYPE>::value,
+ "nVersion has wrong type");
+
+ if (a->nSize < sizeof(*a)) {
+ ALOGE("b/27207275: need %zu, got %u", sizeof(*a), a->nSize);
+ android_errorWriteLog(0x534e4554, "27207275");
+ return false;
+ }
+ return true;
+}
+
} // namespace android
#endif // SOFT_OMX_COMPONENT_H_