Commit c7f241fa authored by Ben Hutchings's avatar Ben Hutchings

unmkinitramfs: Unpack early and main cpio archives in separate directories

Otherwise this can probably be used to overwrite arbitrary files.
Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
parent 12744ebc
...@@ -72,7 +72,7 @@ splitinitramfs() ...@@ -72,7 +72,7 @@ splitinitramfs()
if [ $offset -ne 0 ]; then if [ $offset -ne 0 ]; then
# uncompressed archive # uncompressed archive
( (
test -z "$dir" || { mkdir -p -- "$dir" && cd -- "$dir"; } test -z "$dir" || { mkdir -p -- "$dir/early" && cd -- "$dir/early"; }
cpio -i "$@" cpio -i "$@"
) < "$initramfs" ) < "$initramfs"
...@@ -81,7 +81,7 @@ splitinitramfs() ...@@ -81,7 +81,7 @@ splitinitramfs()
trap "rm -f '$subarchive'" EXIT trap "rm -f '$subarchive'" EXIT
dd < "$initramfs" bs="$offset" skip=1 2> /dev/null \ dd < "$initramfs" bs="$offset" skip=1 2> /dev/null \
> $subarchive > $subarchive
xcpio "$subarchive" "$dir" -i "$@" xcpio "$subarchive" "$dir/main" -i "$@"
else else
xcpio "$initramfs" "$dir" -i "$@" xcpio "$initramfs" "$dir" -i "$@"
fi fi
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment