diff options
Diffstat (limited to 'lib/decompress_unlz4.c')
| -rw-r--r-- | lib/decompress_unlz4.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/lib/decompress_unlz4.c b/lib/decompress_unlz4.c index 1b0baf3008ea..c0dbb3cea915 100644 --- a/lib/decompress_unlz4.c +++ b/lib/decompress_unlz4.c @@ -1,11 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0-only /* * Wrapper for decompressing LZ4-compressed kernel, initramfs, and initrd * * Copyright (C) 2013, LG Electronics, Kyungsik Lee <kyungsik.lee@lge.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. */ #ifdef STATIC @@ -19,7 +16,7 @@ #include <linux/decompress/mm.h> #include <linux/compiler.h> -#include <asm/unaligned.h> +#include <linux/unaligned.h> /* * Note: Uncompressed chunk size is used in the compressor side @@ -115,6 +112,9 @@ STATIC inline int INIT unlz4(u8 *input, long in_len, error("data corrupted"); goto exit_2; } + } else if (size < 4) { + /* empty or end-of-file */ + goto exit_3; } chunksize = get_unaligned_le32(inp); @@ -128,6 +128,10 @@ STATIC inline int INIT unlz4(u8 *input, long in_len, continue; } + if (!fill && chunksize == 0) { + /* empty or end-of-file */ + goto exit_3; + } if (posp) *posp += 4; @@ -187,6 +191,7 @@ STATIC inline int INIT unlz4(u8 *input, long in_len, } } +exit_3: ret = 0; exit_2: if (!input) |
