On Thu, Aug 15, 2013 at 12:32 PM, Simon Glass <s...@chromium.org> wrote: > Hi Kees, > > On Thu, Aug 15, 2013 at 11:19 AM, Kees Cook <keesc...@chromium.org> wrote: >> On Wed, Aug 14, 2013 at 10:30 AM, Simon Glass <s...@chromium.org> wrote: >>> Hi Kees, >>> >>> On Mon, Aug 12, 2013 at 4:48 PM, Kees Cook <keesc...@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 <keesc...@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 >>>> >>>> diff --git a/include/configs/sandbox.h b/include/configs/sandbox.h >>>> index 98dd083..b7fe14d 100644 >>>> --- a/include/configs/sandbox.h >>>> +++ b/include/configs/sandbox.h >>>> @@ -125,4 +125,9 @@ >>>> "stdout=serial\0" \ >>>> "stderr=serial\0" >>>> >>>> +#define CONFIG_GZIP_COMPRESSED >>>> +#define CONFIG_BZIP2 >>>> +#define CONFIG_LZO >>>> +#define CONFIG_LZMA >>>> + >>>> #endif >>>> diff --git a/test/Makefile b/test/Makefile >>>> index 83594f3..ede113d 100644 >>>> --- a/test/Makefile >>>> +++ b/test/Makefile >>>> @@ -25,6 +25,7 @@ include $(TOPDIR)/config.mk >>>> LIB = $(obj)libtest.o >>>> >>>> COBJS-$(CONFIG_SANDBOX) += command_ut.o >>>> +COBJS-$(CONFIG_SANDBOX) += compression.o >>>> >>>> COBJS := $(sort $(COBJS-y)) >>>> SRCS := $(COBJS:.o=.c) >>>> diff --git a/test/compression.c b/test/compression.c >>>> new file mode 100644 >>>> index 0000000..c78c8e4 >>>> --- /dev/null >>>> +++ b/test/compression.c >>>> @@ -0,0 +1,384 @@ >>>> +/* >>>> + * Copyright (c) 2013, The Chromium Authors >>>> + * >>>> + * See file CREDITS for list of people who contributed to this >>>> + * project. >>>> + * >>>> + * This program is free software; you can redistribute it and/or >>>> + * modify it under the terms of the GNU General Public License as >>>> + * published by the Free Software Foundation; either version 2 of >>>> + * the License, or (at your option) any later version. >>>> + * >>>> + * This program is distributed in the hope that it will be useful, >>>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of >>>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >>>> + * GNU General Public License for more details. >>>> + * >>>> + * You should have received a copy of the GNU General Public License >>>> + * along with this program; if not, write to the Free Software >>>> + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, >>>> + * MA 02111-1307 USA >>> >>> I believe we are moving to a new license structure, although I'm not >>> sure how this affects new patches. See Licenses/README. >> >> That file doesn't exist, and I don't see anything named "*icense*" in >> the tree? I must be looking in the wrong place? > > It updated fairly recently, but the tree is > http://git.denx.de/u-boot.git, branch master.
Ah, I was behind. :) Fixed now! > >> >>>> + */ >>>> + >>>> +#define DEBUG >>>> + >>>> +#include <common.h> >>>> +#include <command.h> >>>> +#include <malloc.h> >>>> + >>>> +#include <u-boot/zlib.h> >>>> +#include <bzlib.h> >>>> + >>>> +#ifdef CONFIG_LZMA >>>> +#include <lzma/LzmaTypes.h> >>>> +#include <lzma/LzmaDec.h> >>>> +#include <lzma/LzmaTools.h> >>>> +#endif /* CONFIG_LZMA */ >>>> + >>>> +#ifdef CONFIG_LZO >>>> +#include <linux/lzo.h> >>>> +#endif /* CONFIG_LZO */ >>> >>> You shouldn't need these #ifdefs. >> >> I do, and the other user (common/cmd_bootm.c) uses them too. > > I tried taking them out and it still builds. Why do you need them? Well, it would blow up it the #defines were removed from the sandbox config. But I guess if this is only ever built in the sandbox, then you're right, it's redundant. I'll drop them all. > > [snip] > >>>> +static int do_test_compression(cmd_tbl_t *cmdtp, int flag, int argc, >>>> + char * const argv[]) >>>> +{ >>>> + int err = 0; >>>> +#ifdef CONFIG_GZIP_COMPRESSED >>>> + err += run_test("gzip", compress_using_gzip, >>>> uncompress_using_gzip); >>>> +#endif >>> >>> I notice that this prints a message from the function - is that correct? >>> >>> testing gzip ... >>> orig_size:350 >>> compressed_size:206 >>> uncompressed_size:350 >>> Deflate need more space to compress left 350 bytes >>> >>> ^^^ message here >>> >>> compress does not overrun >>> Error: inflate() returned -5 >>> uncompress does not overrun >>> gzip: ok >> >> Both "Deflate need more space to compress left 350 bytes" and "Error: >> inflate() returned -5" come from the respective compression libraries. >> I opted to leave those things unchanged. Should they be eliminated? > > I don't think you need to worry about it - I was only checking that it > was correct. Sounds like it is. Okay, cool. >> Thanks for the review! > > You're welcome, and thanks for fixing this and especially for adding tests! > >> >> -Kees >> >> -- >> Kees Cook >> Chrome OS Security > > Regards, > Simon v2 on its way... let's see if mailing tries to bounce them all again. :) -Kees -- Kees Cook Chrome OS Security _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot