Skip to content

Commit 0b7f33f

Browse files
Document how tested prefix lengths are chosen
1 parent 84984ae commit 0b7f33f

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

tests/suites/test_suite_asn1parse.function

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,10 @@ void parse_prefixes( const data_t *input,
188188
size_t buffer_size;
189189
int ret;
190190

191+
/* Test every prefix of the input, except the empty string.
192+
* The first byte of the string is the tag. Without a tag byte,
193+
* we wouldn't know what to parse the input as.
194+
*/
191195
for( buffer_size = 1; buffer_size <= input->len; buffer_size++ )
192196
{
193197
test_set_step( buffer_size );
@@ -224,6 +228,12 @@ void get_len( const data_t *input, int actual_length_arg )
224228
size_t actual_length = actual_length_arg;
225229
size_t buffer_size;
226230

231+
/* Test prefixes of a buffer containing the given length string
232+
* followed by `actual_length` bytes of payload. To save a bit of
233+
* time, we skip some "boring" prefixes: we don't test prefixes where
234+
* the payload is truncated more than one byte away from either end,
235+
* and we only test the empty string on a 1-byte input.
236+
*/
227237
for( buffer_size = 1; buffer_size <= input->len + 1; buffer_size++ )
228238
{
229239
if( ! get_len_step( input, buffer_size, actual_length ) )

0 commit comments

Comments
 (0)