diff options
author | Florian Festi <ffesti@redhat.com> | 2022-07-04 13:38:06 +0200 |
---|---|---|
committer | Panu Matilainen <pmatilai@redhat.com> | 2022-09-02 08:48:10 +0300 |
commit | aa38c08d093006df7d5b8269d33c8f05a6a95495 (patch) | |
tree | 81f214ae466f1b6ef5eeb2648694bd87b6516bec | |
parent | 3eb1d72c3c95f51394acab4f9b68116d055b9c50 (diff) | |
download | rpm-aa38c08d093006df7d5b8269d33c8f05a6a95495.tar.gz |
rpm2cpio.sh: Deal with null byte in lzma magic
As the shell can't deal with null bytes only read two bytes and check
for proper match. This way we can match for the null byte even if it is
not part of the string.
This also silents the warning from the shell that there is a null byte
being ignored in the magic string for lzma.
(cherry picked from commit f3b263610b2bac53c48b960490eaa6575215aafe)
-rwxr-xr-x | scripts/rpm2cpio.sh | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/scripts/rpm2cpio.sh b/scripts/rpm2cpio.sh index 59e8bc518..d76717bbd 100755 --- a/scripts/rpm2cpio.sh +++ b/scripts/rpm2cpio.sh @@ -54,11 +54,11 @@ sigsize=$rsize calcsize $(($offset + (8 - ($sigsize % 8)) % 8)) hdrsize=$rsize -case "$(_dd $offset bs=3 count=1 | tr -d '\0')" in - "$(printf '\102\132')"*) _dd $offset | bunzip2 ;; # '\x42\x5a' - "$(printf '\037\213')"*) _dd $offset | gunzip ;; # '\x1f\x8b' - "$(printf '\375\067')"*) _dd $offset | xzcat ;; # '\xfd\x37' - "$(printf '\135\000')"*) _dd $offset | unlzma ;; # '\x5d\x00' - "$(printf '\050\265')"*) _dd $offset | unzstd ;; # '\x28\xb5' +case "$(_dd $offset bs=2 count=1 | tr -d '\0')" in + "$(printf '\102\132')") _dd $offset | bunzip2 ;; # '\x42\x5a' + "$(printf '\037\213')") _dd $offset | gunzip ;; # '\x1f\x8b' + "$(printf '\375\067')") _dd $offset | xzcat ;; # '\xfd\x37' + "$(printf '\135')") _dd $offset | unlzma ;; # '\x5d\x00' + "$(printf '\050\265')") _dd $offset | unzstd ;; # '\x28\xb5' *) fatal "Unrecognized rpm file: $pkg" ;; esac |