]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
added decode_proto test point, and dhcpv6 fuzzer
authorAlan T. DeKok <aland@freeradius.org>
Tue, 29 Oct 2019 18:41:31 +0000 (14:41 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Tue, 29 Oct 2019 18:41:31 +0000 (14:41 -0400)
src/bin/.gitignore
src/bin/all.mk
src/protocols/dhcpv6/decode.c

index 78bb33ea7001e7965a2ec90c39b789290d84c82c..c9c40d67e334ec0a63aae1e5e01b7df47f6b7d0f 100644 (file)
@@ -2,3 +2,4 @@ checkrad
 radlast
 radtest
 fuzzer_radius.mk
+fuzzer_dhcpv6.mk
index b13bd40bb9432e5fd502dfc1cb6788a089c8eb43..a24b3c4576a28a8c5081a7dfff19e63b5b9dae1c 100644 (file)
@@ -34,7 +34,7 @@ endef
 #  have a test point for packet decoding.  See
 #  src/protocols/radius/decode.c for an example.
 #
-PROTOCOLS = radius
+PROTOCOLS = radius dhcpv6
 
 $(foreach X,${PROTOCOLS},$(eval $(call FUZZ_PROTOCOL,${X})))
 endif
index 57ef7fcd7946d89915774e43f375f103ae8ea1fa..96d9a7252f478ad5d3040e4ff6e99451a3f53e1f 100644 (file)
@@ -348,6 +348,23 @@ static int decode_test_ctx(void **out, TALLOC_CTX *ctx)
        return 0;
 }
 
+static ssize_t fr_dhcpv6_decode_proto(void *proto_ctx, uint8_t const *data, size_t data_len)
+{
+       ssize_t rcode;
+       size_t packet_len = data_len;
+       VALUE_PAIR *vp = NULL;
+       fr_dhcpv6_decode_ctx_t  *test_ctx = talloc_get_type_abort(proto_ctx, fr_dhcpv6_decode_ctx_t);
+
+       if (!fr_dhcpv6_ok(data, packet_len, 200)) return -1;
+
+       rcode = fr_dhcpv6_decode(test_ctx, data, packet_len, &vp);
+       fr_pair_list_free(&vp);
+       talloc_free_children(test_ctx->tmp_ctx);
+
+       return rcode;
+}
+
+
 /*
  *     Test points
  */
@@ -356,3 +373,9 @@ fr_test_point_pair_decode_t dhcpv6_tp_decode_pair = {
        .test_ctx       = decode_test_ctx,
        .func           = fr_dhcpv6_decode_option
 };
+
+extern fr_test_point_proto_decode_t dhcpv6_tp_decode_proto;
+fr_test_point_proto_decode_t dhcpv6_tp_decode_proto = {
+       .test_ctx       = decode_test_ctx,
+       .func           = fr_dhcpv6_decode_proto
+};