summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmilian Peev <epeev@google.com>2019-07-30 14:48:48 -0700
committerandroid-build-merger <android-build-merger@google.com>2019-07-30 14:48:48 -0700
commit47773cc7bf95c2162b9e9dd6a7210f7a17b759e6 (patch)
treecd524d1c44ed5ba56e86e6ff9a0fbf7505cc0160
parentec1886060e0b8fea37755631cbcc5d331ecd1ec5 (diff)
parentfa436baa99d762b4b528e2c4319ad5c692c32084 (diff)
downloaddynamic_depth-47773cc7bf95c2162b9e9dd6a7210f7a17b759e6.tar.gz
Check Android container item MIME type am: 8facf7af35 am: cfc5a976af
am: fa436baa99 Change-Id: Id34aa26b6383b5fa833700302de964681b119b5e
-rw-r--r--internal/dynamic_depth/depth_jpeg.cc13
1 files changed, 13 insertions, 0 deletions
diff --git a/internal/dynamic_depth/depth_jpeg.cc b/internal/dynamic_depth/depth_jpeg.cc
index 396a41e..af2ead9 100644
--- a/internal/dynamic_depth/depth_jpeg.cc
+++ b/internal/dynamic_depth/depth_jpeg.cc
@@ -19,6 +19,7 @@ namespace dynamic_depth {
int32_t ValidateAndroidDynamicDepthBuffer(const char* buffer, size_t buffer_length) {
XmpData xmp_data;
+ std::string itemMime("image/jpeg");
const string image_data(buffer, buffer_length);
ReadXmpFromMemory(image_data, /*XmpSkipExtended*/ false, &xmp_data);
@@ -29,6 +30,18 @@ int32_t ValidateAndroidDynamicDepthBuffer(const char* buffer, size_t buffer_leng
return -1;
}
+ // Check the container items mime type
+ if ((device->GetContainer() == nullptr) || (device->GetContainer()->GetItems().empty())) {
+ LOG(ERROR) << "No container or container items found!";
+ return -1;
+ }
+ auto items = device->GetContainer()->GetItems();
+ for (const auto& item : items) {
+ if (item->GetMime() != itemMime) {
+ LOG(ERROR) << "Item MIME type doesn't match the expected value: " << itemMime;
+ return -1;
+ }
+ }
// Check profiles
const Profiles* profiles = device->GetProfiles();
if (profiles == nullptr) {