From ef4183858ac8b86a46c12248aa7e705ecddd215b Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Tue, 21 Jan 2020 18:56:27 +0100 Subject: [PATCH] Document how tested prefix lengths are chosen --- tests/suites/test_suite_asn1parse.function | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/suites/test_suite_asn1parse.function b/tests/suites/test_suite_asn1parse.function index d747cc254f..63e3a31c7e 100644 --- a/tests/suites/test_suite_asn1parse.function +++ b/tests/suites/test_suite_asn1parse.function @@ -185,6 +185,10 @@ void parse_prefixes( const data_t *input, size_t buffer_size; int ret; + /* Test every prefix of the input, except the empty string. + * The first byte of the string is the tag. Without a tag byte, + * we wouldn't know what to parse the input as. + */ for( buffer_size = 1; buffer_size <= input->len; buffer_size++ ) { test_set_step( buffer_size ); @@ -221,6 +225,12 @@ void get_len( const data_t *input, int actual_length_arg ) size_t actual_length = actual_length_arg; size_t buffer_size; + /* Test prefixes of a buffer containing the given length string + * followed by `actual_length` bytes of payload. To save a bit of + * time, we skip some "boring" prefixes: we don't test prefixes where + * the payload is truncated more than one byte away from either end, + * and we only test the empty string on a 1-byte input. + */ for( buffer_size = 1; buffer_size <= input->len + 1; buffer_size++ ) { if( ! get_len_step( input, buffer_size, actual_length ) )