From: Hongfei Shang <shfwin6@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: Hongfei Shang <shanghongfei@kylinos.cn>
Subject: [PATCH] initramfs: fix "Decoding failed"
Date: Wed, 30 Dec 2020 13:59:40 +0800 [thread overview]
Message-ID: <20201230055940.17784-1-shfwin6@gmail.com> (raw)
From: Hongfei Shang <shanghongfei@kylinos.cn>
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
Signed-off-by: Hongfei Shang <shanghongfei@kylinos.cn>
---
lib/decompress_unlz4.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/lib/decompress_unlz4.c b/lib/decompress_unlz4.c
index c0cfcfd486be..7527f1541dfd 100644
--- a/lib/decompress_unlz4.c
+++ b/lib/decompress_unlz4.c
@@ -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;
+ }
}
}
--
2.25.1
reply other threads:[~2020-12-30 6:00 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201230055940.17784-1-shfwin6@gmail.com \
--to=shfwin6@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=shanghongfei@kylinos.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox