Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 99b7e93c authored by Krzysztof Kolasa's avatar Krzysztof Kolasa Committed by Greg Kroah-Hartman
Browse files

lz4: fix system halt at boot kernel on x86_64



Sometimes, on x86_64, decompression fails with the following
error:

Decompressing Linux...

Decoding failed

 -- System halted

This condition is not needed for a 64bit kernel(from commit d5e7cafd):

if( ... ||
    (op + COPYLENGTH) > oend)
    goto _output_error

macro LZ4_SECURE_COPY() tests op and does not copy any data
when op exceeds the value.

added by analogy to lz4_uncompress_unknownoutputsize(...)

Signed-off-by: default avatarKrzysztof Kolasa <kkolasa@winsoft.pl>
Tested-by: default avatarAlexander Kuleshov <kuleshovmail@gmail.com>
Tested-by: default avatarCaleb Jorden <cjorden@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 61a590fa
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -140,8 +140,12 @@ static int lz4_uncompress(const char *source, char *dest, int osize)
			/* Error: request to write beyond destination buffer */
			if (cpy > oend)
				goto _output_error;
#if LZ4_ARCH64
			if ((ref + COPYLENGTH) > oend)
#else
			if ((ref + COPYLENGTH) > oend ||
					(op + COPYLENGTH) > oend)
#endif
				goto _output_error;
			LZ4_SECURECOPY(ref, op, (oend - COPYLENGTH));
			while (op < cpy)
@@ -266,7 +270,13 @@ static int lz4_uncompress_unknownoutputsize(const char *source, char *dest,
		if (cpy > oend - COPYLENGTH) {
			if (cpy > oend)
				goto _output_error; /* write outside of buf */

#if LZ4_ARCH64
			if ((ref + COPYLENGTH) > oend)
#else
			if ((ref + COPYLENGTH) > oend ||
					(op + COPYLENGTH) > oend)
#endif
				goto _output_error;
			LZ4_SECURECOPY(ref, op, (oend - COPYLENGTH));
			while (op < cpy)
				*op++ = *ref++;