Skip to contentSkip to conversation

initramfs: fix "Decoding failed"

PATCH New Hongfei Shang 1 participant 1 message Dec 30, 2020 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 initramfs: fix "Decoding failed"

From: Hongfei Shang <[email protected]>

when initrd image file load in memory, it is align to 4 bytes, so there are may be some padding bytes(<4),
should ignore these padding bytes and handle as normal end

before: (when size of initrd.img is: size%4 = 1, 2 or 3) "Initramfs unpacking failed: Decoding failed"

after:
no error message

---
 lib/decompress_unlz4.c | 8 ++++++++
 1 file changed, 8 insertions(+)
lib/decompress_unlz4.c +8 -0
index c0cfcfd486be..7527f1541dfd 100644
@@ -181,6 +181,14 @@ STATIC inline int INIT unlz4(u8 *input, long in_len,
 				goto exit_2;
 			}
 			inp += chunksize;
+
+			if (size < 4) {
+				unsigned int padding = 0;
+
+				memcpy(&padding, inp, size);
+				if (padding == 0)
+					break;
+			}
 		}
 	}
 
Signature · 1 line
2.25.1