Gentoo Archives: gentoo-portage-dev

From: "Michał Górny" <mgorny@g.o>
To: gentoo-portage-dev@l.g.o
Cc: "Michał Górny" <mgorny@g.o>
Subject: [gentoo-portage-dev] [PATCH v2 2/3] ecompress: Fix crash on duplicate compressed & uncompressed files
Date: Tue, 25 Sep 2018 19:54:05
Message-Id: 20180925195349.23527-2-mgorny@gentoo.org
In Reply to: [gentoo-portage-dev] [PATCH v2 1/3] ecompress: delete *.ecompress for empty PORTAGE_COMPRESS (bug 667008) by "Michał Górny"
1 Fix crash due to race condition in handling the same file being present
2 both in compressed and uncompressed variants. If that is the case,
3 just queue the uncompressed variant for compression, and ignore
4 the other compressed variants.
5
6 Bug: https://bugs.gentoo.org/667072
7 Signed-off-by: Michał Górny <mgorny@g.o>
8 ---
9 bin/ecompress | 7 +++++++
10 1 file changed, 7 insertions(+)
11
12 diff --git a/bin/ecompress b/bin/ecompress
13 index 36bdb585b..d5ff3796c 100755
14 --- a/bin/ecompress
15 +++ b/bin/ecompress
16 @@ -49,6 +49,13 @@ while [[ $# -gt 0 ]] ; do
17 find_args+=( -size "+${PORTAGE_DOCOMPRESS_SIZE_LIMIT}c" )
18
19 while IFS= read -d '' -r path; do
20 + # if both compressed and uncompressed variant exists,
21 + # skip the compressed variants (bug #667072)
22 + case ${path} in
23 + *.Z|*.gz|*.bz2|*.lzma|*.xz)
24 + [[ -s ${path%.*} ]] && continue
25 + ;;
26 + esac
27 >> "${path}.ecompress" || die
28 done < <(find "${find_args[@]}" -print0 || die)
29 fi
30 --
31 2.19.0