Fix crash due to race condition in handling the same file being present
both in compressed and uncompressed variants.  If that is the case,
just queue the uncompressed variant for compression, and ignore
the other compressed variants.

Bug: https://bugs.gentoo.org/667072
Signed-off-by: Michał Górny <[email protected]>
---
 bin/ecompress | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/bin/ecompress b/bin/ecompress
index 36bdb585b..d5ff3796c 100755
--- a/bin/ecompress
+++ b/bin/ecompress
@@ -49,6 +49,13 @@ while [[ $# -gt 0 ]] ; do
                                find_args+=( -size 
"+${PORTAGE_DOCOMPRESS_SIZE_LIMIT}c" )
 
                        while IFS= read -d '' -r path; do
+                               # if both compressed and uncompressed variant 
exists,
+                               # skip the compressed variants (bug #667072)
+                               case ${path} in
+                                       *.Z|*.gz|*.bz2|*.lzma|*.xz)
+                                               [[ -s ${path%.*} ]] && continue
+                                               ;;
+                               esac
                                >> "${path}.ecompress" || die
                        done < <(find "${find_args[@]}" -print0 || die)
                fi
-- 
2.19.0


Reply via email to