From: Alan T. DeKok Date: Tue, 29 Oct 2019 18:41:31 +0000 (-0400) Subject: added decode_proto test point, and dhcpv6 fuzzer X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1781dc3565fb376d29e47dfd67a00100edb21228;p=thirdparty%2Ffreeradius-server.git added decode_proto test point, and dhcpv6 fuzzer --- diff --git a/src/bin/.gitignore b/src/bin/.gitignore index 78bb33ea700..c9c40d67e33 100644 --- a/src/bin/.gitignore +++ b/src/bin/.gitignore @@ -2,3 +2,4 @@ checkrad radlast radtest fuzzer_radius.mk +fuzzer_dhcpv6.mk diff --git a/src/bin/all.mk b/src/bin/all.mk index b13bd40bb94..a24b3c4576a 100644 --- a/src/bin/all.mk +++ b/src/bin/all.mk @@ -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 diff --git a/src/protocols/dhcpv6/decode.c b/src/protocols/dhcpv6/decode.c index 57ef7fcd794..96d9a7252f4 100644 --- a/src/protocols/dhcpv6/decode.c +++ b/src/protocols/dhcpv6/decode.c @@ -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 +};