[U-Boot] [PATCH 1/6] sandbox: add compression tests

Kees Cook keescook at chromium.org
Fri Aug 16 16:14:02 CEST 2013


On Thu, Aug 15, 2013 at 10:19 AM, Kees Cook <keescook at chromium.org> wrote:
> On Wed, Aug 14, 2013 at 10:30 AM, Simon Glass <sjg at chromium.org> wrote:
>> On Mon, Aug 12, 2013 at 4:48 PM, Kees Cook <keescook at chromium.org> wrote:
>>> This adds the "test_compression" command when building the sandbox. This
>>> tests the existing compression and decompression routines for simple
>>> sanity and for buffer overflow conditions.
>>>
>>> Signed-off-by: Kees Cook <keescook at chromium.org>
>>> ---
>>>  include/configs/sandbox.h |    5 +
>>>  test/Makefile             |    1 +
>>>  test/compression.c        |  384 +++++++++++++++++++++++++++++++++++++++++++++
>>>  3 files changed, 390 insertions(+)
>>>  create mode 100644 test/compression.c
>>>
[snip]
>>> diff --git a/test/compression.c b/test/compression.c
>>> new file mode 100644
>>> index 0000000..c78c8e4
>>> --- /dev/null
>>> +++ b/test/compression.c
[snip[
>>> +static int compress_using_bzip2(void *in, unsigned long in_size,
>>> +                               void *out, unsigned long out_max,
>>> +                               unsigned long *out_size)
>>> +{
>>> +       /* There is no bzip2 compression in u-boot, so fake it. */
>>> +       assert(in_size == strlen(plain));
>>> +       assert(memcmp(plain, in, in_size) == 0);
>>> +
>>> +       if (bzip2_compressed_size > out_max)
>>
>> debug() here?
>
> Sure, I'll add calls at these failure points.

Ah, I take that back. These tests get hit during normal testing. I'd
rather leave the debug() calls out since they're expected to be
exercised.

-Kees

-- 
Kees Cook
Chrome OS Security


More information about the U-Boot mailing list