diff options
author | Julius Werner <jwerner@chromium.org> | 2016-02-08 11:46:22 -0800 |
---|---|---|
committer | Julius Werner <jwerner@chromium.org> | 2016-02-12 22:00:55 +0100 |
commit | a25b5d257dbfbff808b19bf8c48565435e6bef9d (patch) | |
tree | a6e818cf02d087ba8173081f0f8cbba1cac67908 /src/lib/selfboot.c | |
parent | d189987fc923daf0709c69946b4a267cb2c374af (diff) |
lzma: Port size-checking ulzman() version to coreboot
We've had a second version of ulzma() that would check the input and
output buffer sizes in libpayload for a while now. Since it's generally
never a bad idea to double-check for overruns, let's port it to coreboot
and use it where applicable. (This requires a small fix in the four byte
at a time read optimization we only have in coreboot, since it made the
stream counter hit the end a little earlier than the algorithm liked and
could trigger an assertion.)
BRANCH=None
BUG=None
TEST=Booted Oak, Jerry and Falco.
Change-Id: Id566b31dfa896ea1b991badf5a6ad9d075aef987
Signed-off-by: Julius Werner <jwerner@chromium.org>
Reviewed-on: https://review.coreboot.org/13637
Tested-by: build bot (Jenkins)
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Diffstat (limited to 'src/lib/selfboot.c')
-rw-r--r-- | src/lib/selfboot.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/lib/selfboot.c b/src/lib/selfboot.c index 60cda6ae9e..6d86159ddd 100644 --- a/src/lib/selfboot.c +++ b/src/lib/selfboot.c @@ -378,12 +378,12 @@ static int load_self_segments( /* Copy data from the initial buffer */ if (ptr->s_filesz) { unsigned char *middle, *end; - size_t len; - len = ptr->s_filesz; + size_t len = ptr->s_filesz; + size_t memsz = ptr->s_memsz; switch(ptr->compression) { case CBFS_COMPRESS_LZMA: { printk(BIOS_DEBUG, "using LZMA\n"); - len = ulzma(src, dest); + len = ulzman(src, len, dest, memsz); if (!len) /* Decompression Error. */ return 0; break; @@ -397,7 +397,7 @@ static int load_self_segments( printk(BIOS_INFO, "CBFS: Unknown compression type %d\n", ptr->compression); return -1; } - end = dest + ptr->s_memsz; + end = dest + memsz; middle = dest + len; printk(BIOS_SPEW, "[ 0x%08lx, %08lx, 0x%08lx) <- %08lx\n", (unsigned long)dest, |