CTS test for Android Security b/68159767

Bug: 68159767
Bug: 72396811
Test: Ran the new testcase on android-8.0.0_r11 with/without patch

Change-Id: I3f13b811063b21d9086a9fc5a02fd9c0b3e985e4
Merged-In: I3f13b811063b21d9086a9fc5a02fd9c0b3e985e4
diff --git a/hostsidetests/securitybulletin/AndroidTest.xml b/hostsidetests/securitybulletin/AndroidTest.xml
index 1255d85..301c175 100644
--- a/hostsidetests/securitybulletin/AndroidTest.xml
+++ b/hostsidetests/securitybulletin/AndroidTest.xml
@@ -173,6 +173,7 @@
         <!--__________________-->
         <!-- Bulletin 2018-02 -->
         <!-- Please add tests solely from this bulletin below to avoid merge conflict -->
+        <option name="push" value="CVE-2017-13234->/data/local/tmp/CVE-2017-13234" />
         <option name="push" value="CVE-2017-0837->/data/local/tmp/CVE-2017-0837" />
         <option name="push" value="CVE-2017-13273->/data/local/tmp/CVE-2017-13273" />
         <option name="push" value="CVE-2017-13232->/data/local/tmp/CVE-2017-13232" />
diff --git a/hostsidetests/securitybulletin/res/cve_2017_13234.xmf b/hostsidetests/securitybulletin/res/cve_2017_13234.xmf
new file mode 100644
index 0000000..3c249fa
--- /dev/null
+++ b/hostsidetests/securitybulletin/res/cve_2017_13234.xmf
Binary files differ
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2017-13234/Android.bp b/hostsidetests/securitybulletin/securityPatch/CVE-2017-13234/Android.bp
new file mode 100644
index 0000000..8ba14a9
--- /dev/null
+++ b/hostsidetests/securitybulletin/securityPatch/CVE-2017-13234/Android.bp
@@ -0,0 +1,40 @@
+/*
+ * 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.
+ *
+ */
+
+cc_test {
+    name: "CVE-2017-13234",
+
+    defaults: ["cts_hostsidetests_securitybulletin_defaults"],
+
+    srcs: [
+        "poc.c",
+        ":cts_hostsidetests_securitybulletin_memutils_track",
+    ],
+
+    include_dirs: [
+        "external/sonivox/arm-wt-22k/host_src",
+    ],
+
+    shared_libs: [
+        "libsonivox",
+    ],
+
+    cflags: [
+        "-DCHECK_MEMORY_LEAK",
+        "-DENABLE_SELECTIVE_OVERLOADING",
+    ],
+}
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2017-13234/poc.c b/hostsidetests/securitybulletin/securityPatch/CVE-2017-13234/poc.c
new file mode 100644
index 0000000..3e9c66b
--- /dev/null
+++ b/hostsidetests/securitybulletin/securityPatch/CVE-2017-13234/poc.c
@@ -0,0 +1,77 @@
+/**
+ * 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.
+ */
+#define _GNU_SOURCE
+#include <stdlib.h>
+#include <string.h>
+#include <stdbool.h>
+#include "../includes/memutils_track.h"
+#include "eas.h"
+
+char enable_selective_overload = ENABLE_NONE;
+
+bool is_tracking_required(size_t size) {
+    return ((size != 1024) && (size != 4096));
+}
+
+int EAS_fread(void *handle, void *buf, int offset, int size) {
+    fseek(handle, offset, SEEK_SET);
+    return fread(buf, 1, size, handle);
+}
+
+int EAS_fsize(void *handle) {
+    fseek(handle, 0, SEEK_END);
+    return ftell(handle);
+}
+
+static void PlayFile(EAS_DATA_HANDLE easData, const char* filename) {
+    EAS_HANDLE handle;
+    EAS_FILE file;
+    file.handle = (void*) fopen(filename, "rb");
+    file.readAt = EAS_fread;
+    file.size = EAS_fsize;
+    enable_selective_overload = ENABLE_MALLOC_CHECK;
+    if (EAS_OpenFile(easData, &file, &handle) != EAS_SUCCESS) {
+        enable_selective_overload = ENABLE_NONE;
+        if(file.handle) {
+            fclose(file.handle);
+        }
+        return;
+    }
+    EAS_Prepare(easData, handle);
+    EAS_CloseFile(easData, handle);
+    enable_selective_overload = ENABLE_NONE;
+    if(file.handle) {
+        fclose(file.handle);
+    }
+    return;
+}
+
+int main(int argc, char **argv) {
+    EAS_DATA_HANDLE easData;
+    EAS_RESULT result;
+
+    if (argc < 2) {
+        return EXIT_FAILURE;
+    }
+
+    result = EAS_Init(&easData);
+    if (result != EAS_SUCCESS) {
+        return EXIT_FAILURE;
+    }
+    PlayFile(easData, argv[1]);
+    EAS_Shutdown(easData);
+    return EXIT_SUCCESS;
+}
diff --git a/hostsidetests/securitybulletin/src/android/security/cts/TestMedia.java b/hostsidetests/securitybulletin/src/android/security/cts/TestMedia.java
index 9aaeaa4..0a17c87 100644
--- a/hostsidetests/securitybulletin/src/android/security/cts/TestMedia.java
+++ b/hostsidetests/securitybulletin/src/android/security/cts/TestMedia.java
@@ -45,6 +45,18 @@
      ******************************************************************************/
 
     /**
+     * b/68159767
+     * Vulnerability Behaviour: EXIT_VULNERABLE (113)
+     */
+    @SecurityTest(minPatchLevel = "2018-02")
+    @Test
+    public void testPocCVE_2017_13234() throws Exception {
+        String inputFiles[] = { "cve_2017_13234.xmf" };
+        AdbUtils.runPocAssertNoCrashesNotVulnerable("CVE-2017-13234",
+                AdbUtils.TMP_PATH + inputFiles[0], inputFiles, AdbUtils.TMP_PATH, getDevice());
+    }
+
+    /**
      * b/74122779
      * Vulnerability Behaviour: SIGABRT in audioserver
      */