[RESTRICT AUTOMERGE] CTS test for Android Security b/62133227

Bug: 62133227
Bug: 72443087
Test: Ran the new testcase on android-8.0.0_r30 to test with/without patch

Change-Id: I9282caad0eddf513359975455816be4bff3c810c
diff --git a/hostsidetests/securitybulletin/AndroidTest.xml b/hostsidetests/securitybulletin/AndroidTest.xml
index 9e55a62..8564d4d 100644
--- a/hostsidetests/securitybulletin/AndroidTest.xml
+++ b/hostsidetests/securitybulletin/AndroidTest.xml
@@ -152,6 +152,7 @@
         <!--__________________-->
         <!-- Bulletin 2017-09 -->
         <!-- Please add tests solely from this bulletin below to avoid merge conflict -->
+        <option name="push" value="CVE-2017-0778->/data/local/tmp/CVE-2017-0778" />
         <option name="push" value="Bug-38195738->/data/local/tmp/Bug-38195738" />
         <option name="push" value="CVE-2017-11041->/data/local/tmp/CVE-2017-11041" />
 
diff --git a/hostsidetests/securitybulletin/res/cve_2017_0778.mp4 b/hostsidetests/securitybulletin/res/cve_2017_0778.mp4
new file mode 100644
index 0000000..84caa5a
--- /dev/null
+++ b/hostsidetests/securitybulletin/res/cve_2017_0778.mp4
Binary files differ
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2017-0778/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2017-0778/Android.mk
new file mode 100644
index 0000000..1c5bad5
--- /dev/null
+++ b/hostsidetests/securitybulletin/securityPatch/CVE-2017-0778/Android.mk
@@ -0,0 +1,34 @@
+#Copyright (C) 2020 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := CVE-2017-0778
+LOCAL_SRC_FILES := poc.cpp
+LOCAL_SRC_FILES += ../includes/memutils.c
+LOCAL_MULTILIB := both
+LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
+LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
+LOCAL_C_INCLUDES := frameworks/av/media/libstagefright
+LOCAL_SHARED_LIBRARIES := libstagefright
+LOCAL_SHARED_LIBRARIES += libutils
+
+LOCAL_COMPATIBILITY_SUITE := cts sts vts
+LOCAL_CTS_TEST_PACKAGE := android.security.cts
+
+LOCAL_ARM_MODE := arm
+LOCAL_CFLAGS += -Wall -Werror -Wno-unused-parameter -DCHECK_OVERFLOW \
+                  -DFORCE_UNALIGN -DENABLE_SELECTIVE_OVERLOADING
+include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2017-0778/poc.cpp b/hostsidetests/securitybulletin/securityPatch/CVE-2017-0778/poc.cpp
new file mode 100644
index 0000000..2eb89c2
--- /dev/null
+++ b/hostsidetests/securitybulletin/securityPatch/CVE-2017-0778/poc.cpp
@@ -0,0 +1,37 @@
+/**
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include <media/stagefright/FileSource.h>
+#include <media/stagefright/MediaExtractor.h>
+#include <media/stagefright/MetaData.h>
+#include "include/MPEG4Extractor.h"
+#include "../includes/memutils.h"
+
+using namespace android;
+char enable_selective_overload = ENABLE_NONE;
+int main(int argc, char **argv) {
+    if (argc < 2) {
+        return EXIT_SUCCESS;
+    }
+    sp < IMediaSource > mediaSource;
+    sp < DataSource > dataSource = new FileSource(argv[1]);
+    MediaExtractor *ret = new MPEG4Extractor(dataSource.get());
+
+    sp < MetaData > metadata;
+    enable_selective_overload = ENABLE_MEMALIGN_CHECK | ENABLE_MALLOC_CHECK;
+    metadata = ret->getMetaData();
+    enable_selective_overload = ENABLE_NONE;
+    return EXIT_SUCCESS;
+}
diff --git a/hostsidetests/securitybulletin/src/android/security/cts/TestMedia.java b/hostsidetests/securitybulletin/src/android/security/cts/TestMedia.java
index 77973a9..faf7479 100644
--- a/hostsidetests/securitybulletin/src/android/security/cts/TestMedia.java
+++ b/hostsidetests/securitybulletin/src/android/security/cts/TestMedia.java
@@ -49,6 +49,17 @@
      ******************************************************************************/
 
     /**
+     * b/62133227
+     * Vulnerability Behaviour: SIGSEGV in self
+     **/
+    @SecurityTest(minPatchLevel = "2017-09")
+    public void testPocCVE_2017_0778() throws Exception {
+        String inputFiles[] = {"cve_2017_0778.mp4"};
+        AdbUtils.runPocAssertNoCrashesNotVulnerable("CVE-2017-0778",
+                AdbUtils.TMP_PATH + inputFiles[0], inputFiles, AdbUtils.TMP_PATH, getDevice());
+    }
+
+    /**
      * b/36576151
      * Vulnerability Behaviour: SIGSEGV in self
      **/