diff options
author | Lasse Collin <lasse.collin@tukaani.org> | 2014-11-10 18:45:01 +0200 |
---|---|---|
committer | Lasse Collin <lasse.collin@tukaani.org> | 2014-11-10 18:45:01 +0200 |
commit | f8c13e5e3609581d5dd9f8777985ca07f2390ad7 (patch) | |
tree | 0930b4b4f1aa71939aa82e7ac3fb49b4c27ccb29 /src/scripts | |
parent | 7716dcf9df7f457500cb657314e7a9aea5fedb06 (diff) | |
download | xz-f8c13e5e3609581d5dd9f8777985ca07f2390ad7.tar.gz |
xzdiff: Create a temporary directory to hold a temporary file.
This avoids the possibility of "File name too long" when
creating a temp file when the input file name is very long.
This also means that other users on the system can no longer
see the input file names in /tmp (or whatever $TMPDIR is)
since the temporary directory will have a generic name. This
usually doesn't matter since on many systems one can see
the arguments given to all processes anyway.
The number X chars to mktemp where increased from 6 to 10.
Note that with some shells temp files or dirs won't be used at all.
Diffstat (limited to 'src/scripts')
-rw-r--r-- | src/scripts/xzdiff.in | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/scripts/xzdiff.in b/src/scripts/xzdiff.in index e6e3842..ea35d26 100644 --- a/src/scripts/xzdiff.in +++ b/src/scripts/xzdiff.in @@ -136,18 +136,18 @@ elif test $# -eq 2; then F=`expr "/$2" : '.*/\(.*\)[-.][ablmotxz2]*$'` || F=$prog tmp= trap ' - test -n "$tmp" && rm -f "$tmp" + test -n "$tmp" && rm -rf "$tmp" (exit 2); exit 2 ' HUP INT PIPE TERM 0 - tmp=`mktemp -t -- "$F.XXXXXX"` || exit 2 - $xz2 -cdfq -- "$2" > "$tmp" || exit 2 + tmp=`mktemp -t -d -- "$prog.XXXXXXXXXX"` || exit 2 + $xz2 -cdfq -- "$2" > "$tmp/$F" || exit 2 xz_status=$( exec 4>&1 ($xz1 -cdfq -- "$1" 4>&-; echo $? >&4) 3>&- | - eval "$cmp" - '"$tmp"' >&3 + eval "$cmp" - '"$tmp/$F"' >&3 ) cmp_status=$? - rm -f "$tmp" || xz_status=$? + rm -rf "$tmp" || xz_status=$? trap - HUP INT PIPE TERM 0 (exit $cmp_status) fi;; |