Document how tested prefix lengths are chosen

This commit is contained in:
Gilles Peskine 2020-01-21 18:56:27 +01:00
parent d27a88438f
commit ef4183858a

View file

@ -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 ) )