diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/lzma.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/lib/lzma.c b/src/lib/lzma.c index f0b88c12e2..cd60b3f3b2 100644 --- a/src/lib/lzma.c +++ b/src/lib/lzma.c @@ -29,9 +29,15 @@ unsigned long ulzma(unsigned char * src, unsigned char * dst) #endif /* in pre-ram, it must go on the stack */ unsigned char scratchpad[15980]; + unsigned char *cp; memcpy(properties, src, LZMA_PROPERTIES_SIZE); - outSize = *(UInt32 *)(src + LZMA_PROPERTIES_SIZE); + /* The outSize in LZMA stream is a 64bit integer stored in little-endian + * (ref: lzma.cc@LZMACompress: put_64). To prevent accessing by + * unaligned memory address and to load in correct endianess, read each + * byte and re-costruct. */ + cp = src + LZMA_PROPERTIES_SIZE; + outSize = cp[3] << 24 | cp[2] << 16 | cp[1] << 8 | cp[0]; if (LzmaDecodeProperties(&state.Properties, properties, LZMA_PROPERTIES_SIZE) != LZMA_RESULT_OK) { printk(BIOS_WARNING, "lzma: Incorrect stream properties.\n"); return 0; |