bzip2/bzip2-1.0.6-bzgrep_return_value.patch
Martin Pluskal c074e654c4 Accepting request 712284 from home:iznogood:branches:Archiving
- Update to version 1.0.7:
  * Fix undefined behavior in the macros SET_BH, CLEAR_BH, &
    ISSET_BH.
  * bzip2: Fix return value when combining --test,-t and -q.
  * bzip2recover: Fix buffer overflow for large argv[0].
  * bzip2recover: Fix use after free issue with outFile
    (CVE-2016-3189).
  * Make sure nSelectors is not out of range (CVE-2019-12900).
- Drop patches fixed upstream:
  * bzip2-unsafe_strcpy.patch.
  * bzip2-1.0.6-CVE-2016-3189.patch.
- Refresh patches with quilt.

OBS-URL: https://build.opensuse.org/request/show/712284
OBS-URL: https://build.opensuse.org/package/show/Archiving/bzip2?expand=0&rev=76
2019-06-28 07:19:41 +00:00

28 lines
924 B
Diff

Index: bzip2-1.0.7/bzgrep
===================================================================
--- bzip2-1.0.7.orig/bzgrep 2019-06-27 23:10:21.375272508 +0200
+++ bzip2-1.0.7/bzgrep 2019-06-27 23:10:21.415272635 +0200
@@ -65,8 +65,20 @@ for i do
else
j=$(echo "$i" | sed 's/\\/&&/g;s/|/\\&/g;s/&/\\&/g')
j=`printf "%s" "$j" | tr '\n' ' '`
- bzip2 -cdfq "$i" | $grep $opt "$pat" | sed "s|^|${j}:|"
- r=$?
+ # A trick adapted from
+ # https://groups.google.com/forum/#!original/comp.unix.shell/x1345iu10eg/Nn1n-1r1uU0J
+ # that has the same effect as the following bash code:
+ # bzip2 -cdfq "$i" | $grep $opt "$pat" | sed "s|^|${j}:|"
+ # r=${PIPESTATUS[1]}
+ exec 3>&1
+ eval `
+ exec 4>&1 >&3 3>&-
+ {
+ bzip2 -cdfq "$i" 4>&-
+ } | {
+ $grep $opt "$pat" 4>&-; echo "r=$?;" >&4
+ } | sed "s|^|${j}:|"
+ `
fi
test "$r" -ne 0 && res="$r"
done