]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
fuzz-dhcp6-client: add prefix hint and vendor option to sent message
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 7 Feb 2022 16:19:50 +0000 (01:19 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 14 Feb 2022 06:02:33 +0000 (15:02 +0900)
src/libsystemd-network/fuzz-dhcp6-client.c

index 32fa68d8a991cc4ad659058ae8f7055c0f08f085..32e35510e53521d0b395ff632026d7b882f67741 100644 (file)
@@ -68,7 +68,10 @@ static void fuzz_client(sd_dhcp6_client *client, const uint8_t *data, size_t siz
 int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
         _cleanup_(sd_event_unrefp) sd_event *e = NULL;
         _cleanup_(sd_dhcp6_client_unrefp) sd_dhcp6_client *client = NULL;
+        _cleanup_(sd_dhcp6_option_unrefp) sd_dhcp6_option *v1 = NULL, *v2 = NULL;
         struct in6_addr address = { { { 0xfe, 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x01 } } };
+        struct in6_addr hint = { { { 0x3f, 0xfe, 0x05, 0x01, 0xff, 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } } };
+        static const char *v1_data = "hogehoge", *v2_data = "foobar";
 
         if (size > 65536)
                 return 0;
@@ -85,6 +88,11 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
         assert_se(sd_dhcp6_client_set_request_mud_url(client, "https://www.example.com/mudfile.json") >= 0);
         assert_se(sd_dhcp6_client_set_request_user_class(client, STRV_MAKE("u1", "u2", "u3")) >= 0);
         assert_se(sd_dhcp6_client_set_request_vendor_class(client, STRV_MAKE("v1", "v2", "v3")) >= 0);
+        assert_se(sd_dhcp6_client_set_prefix_delegation_hint(client, 48, &hint) >= 0);
+        assert_se(sd_dhcp6_option_new(123, v1_data, strlen(v1_data), 12345, &v1) >= 0);
+        assert_se(sd_dhcp6_option_new(456, v2_data, strlen(v2_data), 45678, &v2) >= 0);
+        assert_se(sd_dhcp6_client_add_vendor_option(client, v1) >= 0);
+        assert_se(sd_dhcp6_client_add_vendor_option(client, v2) >= 0);
 
         fuzz_client(client, data, size, DHCP6_STATE_INFORMATION_REQUEST);
         fuzz_client(client, data, size, DHCP6_STATE_SOLICITATION);