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

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

Change-Id: I8b9ff1591bf01bb4986210f3026e635d0471bbc5
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2019-2179/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2019-2179/Android.mk
new file mode 100644
index 0000000..2e0502b
--- /dev/null
+++ b/hostsidetests/securitybulletin/securityPatch/CVE-2019-2179/Android.mk
@@ -0,0 +1,35 @@
+# 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-2019-2179
+LOCAL_SRC_FILES := poc.cpp
+LOCAL_MULTILIB := both
+LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
+LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
+LOCAL_C_INCLUDES := system/nfc/src/nfc/include/
+LOCAL_C_INCLUDES += system/nfc/src/include/
+LOCAL_C_INCLUDES += system/nfc/src/gki/ulinux/
+LOCAL_C_INCLUDES += system/nfc/src/hal/include/
+LOCAL_SHARED_LIBRARIES := libnfc-nci
+
+# Tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts sts vts
+LOCAL_CTS_TEST_PACKAGE := android.security.cts
+
+LOCAL_ARM_MODE := arm
+LOCAL_CFLAGS := -Wall -Werror
+include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2019-2179/poc.cpp b/hostsidetests/securitybulletin/securityPatch/CVE-2019-2179/poc.cpp
new file mode 100644
index 0000000..6b1c05d
--- /dev/null
+++ b/hostsidetests/securitybulletin/securityPatch/CVE-2019-2179/poc.cpp
@@ -0,0 +1,36 @@
+/*
+ * 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 <stdlib.h>
+#include "../includes/common.h"
+
+// This PoC is only for 32-bit builds
+#if _32_BIT
+#include <ndef_utils.h>
+#endif /* _32_BIT */
+
+int main() {
+// This PoC is only for 32-bit builds
+#if _32_BIT
+    uint8_t p_msg[] = { NDEF_IL_MASK | NDEF_MB_MASK | 0x3, NDEF_MB_MASK,
+            NDEF_MB_MASK, NDEF_MB_MASK, NDEF_MB_MASK, NDEF_MB_MASK,
+            NDEF_MB_MASK, NDEF_MB_MASK };
+    uint32_t msg_len = sizeof(p_msg) / sizeof(uint8_t);
+    bool b_allow_chunks = false;
+    NDEF_MsgValidate(p_msg, msg_len, b_allow_chunks);
+#endif /* _32_BIT */
+    return EXIT_SUCCESS;
+}
diff --git a/hostsidetests/securitybulletin/src/android/security/cts/TestMedia.java b/hostsidetests/securitybulletin/src/android/security/cts/TestMedia.java
index 062a6ec..8341219 100644
--- a/hostsidetests/securitybulletin/src/android/security/cts/TestMedia.java
+++ b/hostsidetests/securitybulletin/src/android/security/cts/TestMedia.java
@@ -54,6 +54,16 @@
      ******************************************************************************/
 
     /**
+     * b/126200054
+     * Vulnerability Behaviour: SIGSEGV in self
+     **/
+    @Test
+    @SecurityTest(minPatchLevel = "2019-09")
+    public void testPocCVE_2019_2179() throws Exception {
+        AdbUtils.runPocAssertNoCrashesNotVulnerable("CVE-2019-2179", null, getDevice());
+    }
+
+    /**
      * b/144767096
      * Vulnerability Behaviour: EXIT_VULNERABLE (113)
      */