AMessage::FromParcel(): Limit recursion depth; report NULL on failure.
- FromParcel() now takes as an optional parameter the maximum recursion depth.
(The default value is currently set to 255.) On the event that the input
parcel has AMessage nested deeper than the maximum recursion depth,
FromParcel() will return NULL.
- Also, when the input parcel has items that are not recognized by FromParcel(),
NULL will be returned. (The old behavior was to invoke TRESPASS, which would
cause the process to stop.)
Bug: 28332724
Change-Id: I722097f7d1711668f197651d7e8135d703f6c91f
diff --git a/media/libmedia/MediaCodecInfo.cpp b/media/libmedia/MediaCodecInfo.cpp
index 06abd8d..1b3b3eb 100644
--- a/media/libmedia/MediaCodecInfo.cpp
+++ b/media/libmedia/MediaCodecInfo.cpp
@@ -75,6 +75,8 @@
}
uint32_t flags = static_cast<uint32_t>(parcel.readInt32());
sp<AMessage> details = AMessage::FromParcel(parcel);
+ if (details == NULL)
+ return NULL;
if (caps != NULL) {
caps->mFlags = flags;
caps->mDetails = details;
@@ -163,6 +165,8 @@
for (size_t i = 0; i < size; i++) {
AString mime = AString::FromParcel(parcel);
sp<Capabilities> caps = Capabilities::FromParcel(parcel);
+ if (caps == NULL)
+ return NULL;
if (info != NULL) {
info->mCaps.add(mime, caps);
}