Mark ab/6881855 as merged

Bug: 172690556
Change-Id: Ie06f21fba8d2dcb1f315dfb7f77487af1262a8fa
diff --git a/Android.bp b/Android.bp
index eaf89a8..524ff65 100644
--- a/Android.bp
+++ b/Android.bp
@@ -33,7 +33,9 @@
 cc_library_headers {
     name: "libbase_headers",
     vendor_available: true,
+    product_available: true,
     ramdisk_available: true,
+    vendor_ramdisk_available: true,
     recovery_available: true,
     host_supported: true,
     native_bridge_supported: true,
@@ -108,13 +110,16 @@
             enabled: true,
         },
     },
+    min_sdk_version: "29",
 }
 
 cc_library {
     name: "libbase",
     defaults: ["libbase_defaults"],
     vendor_available: true,
+    product_available: true,
     ramdisk_available: true,
+    vendor_ramdisk_available: true,
     recovery_available: true,
     host_supported: true,
     native_bridge_supported: true,
@@ -133,7 +138,6 @@
         "//apex_available:anyapex",
         "//apex_available:platform",
     ],
-    min_sdk_version: "29",
 }
 
 cc_library_static {
@@ -241,3 +245,18 @@
         },
     },
 }
+
+cc_fuzz {
+    name: "libbase_parsenetaddress_fuzzer",
+    shared_libs: ["libbase"],
+    host_supported: true,
+    srcs: ["parsenetaddress_fuzzer.cpp"],
+    dictionary: "parsenetaddress_fuzzer.dict",
+
+    fuzz_config: {
+        cc: [
+            "android-bionic@google.com",
+        ],
+        componentid: 128577
+    }
+}
diff --git a/PREUPLOAD.cfg b/PREUPLOAD.cfg
new file mode 100644
index 0000000..dcf92be
--- /dev/null
+++ b/PREUPLOAD.cfg
@@ -0,0 +1,8 @@
+[Builtin Hooks]
+clang_format = true
+
+[Builtin Hooks Options]
+clang_format = --commit ${PREUPLOAD_COMMIT} --style file --extensions c,h,cc,cpp
+
+[Hook Scripts]
+aosp_hook = ${REPO_ROOT}/frameworks/base/tools/aosp/aosp_sha.sh ${PREUPLOAD_COMMIT} "."
diff --git a/parsenetaddress_fuzzer.cpp b/parsenetaddress_fuzzer.cpp
new file mode 100644
index 0000000..382c139
--- /dev/null
+++ b/parsenetaddress_fuzzer.cpp
@@ -0,0 +1,29 @@
+/*
+ * 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 <fuzzer/FuzzedDataProvider.h>
+
+#include "android-base/parsenetaddress.h"
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t length) {
+  FuzzedDataProvider dataProvider(data, length);
+  std::string contents = dataProvider.ConsumeRemainingBytesAsString();
+  std::string canonical, host, error;
+  int port = 123;
+  android::base::ParseNetAddress(contents, &host, &port, &canonical, &error);
+
+  return 0;
+}
diff --git a/parsenetaddress_fuzzer.dict b/parsenetaddress_fuzzer.dict
new file mode 100644
index 0000000..3aa7760
--- /dev/null
+++ b/parsenetaddress_fuzzer.dict
@@ -0,0 +1,34 @@
+# Values from the parsenetaddress_test.cpp unit test
+
+"www.google.com"
+"www.google.com:123"
+"www.google.com"
+"www.google.com:666"
+"1.2.3.4"
+"1.2.3.4:123"
+"1.2.3.4"
+"1.2.3.4:666"
+"::1"
+"[::1]:123"
+"fe80::200:5aee:feaa:20a2"
+"[fe80::200:5aee:feaa:20a2]:123"
+"fe80::200:5aee:feaa:20a2"
+"[::1]:666"
+"[fe80::200:5aee:feaa:20a2]:666"
+"1.2.3.4:"
+"1.2.3.4::"
+":123"
+":1"
+"::::::::1"
+"[::1"
+"[::1]"
+"[::1]:"
+"[::1]::"
+"1.2.3.4:-1"
+"1.2.3.4:0"
+"1.2.3.4:65536"
+"1.2.3.4:hello"
+"[::1]:-1"
+"[::1]:0"
+"[::1]:65536"
+"[::1]:hello"