Skip to content

Commit

Permalink
rpm2cpio.sh: Don't drop newlines from header sizes
Browse files Browse the repository at this point in the history
This script converts binary header sizes to decimal numbers. Shell is
not that well suited for this task as it drops newlines at the end of
command substitutions. Add a . character at the end and strip it right
after that to avoid this problem.

Resolves: rhbz#1983015
  • Loading branch information
ffesti authored and dmnks committed Jul 13, 2022
1 parent ba31a14 commit a18a119
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion scripts/rpm2cpio.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ calcsize() {

i=0
while [ $i -lt 8 ]; do
b="$(_dd $(($offset + $i)) bs=1 count=1)"
# add . to not loose \n
# strip \0 as it gets dropped with warning otherwise
b="$(_dd $(($offset + $i)) bs=1 count=1 | tr -d '\0' ; echo .)"
b=${b%.} # strip . again

[ -z "$b" ] &&
b="0" ||
b="$(exec printf '%u\n' "'$b")"
Expand Down

0 comments on commit a18a119

Please sign in to comment.