Upstream: https://anonscm.debian.org/cgit/collab-maint/tardiff.git/tree/debian/patches/CVE-2015-0858.diff
Description: Fix race condition when creating temporary files (CVE-2015-0858)
Reported by Florian Weimer <fw@deneb.enyo.de>. Implemented using
File::Temp instead of just using the process ID inside the directory
name as suggested by Florian.
Author: Axel Beckert <abe@debian.org>
Bug-CVE: https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2015-0858
|
|
|
7 | 7 | |
8 | 8 | use strict; |
9 | 9 | use Text::Diff; |
| 10 | use File::Temp qw(tempdir); |
10 | 11 | |
11 | 12 | my $VERSION = '0.1'; |
12 | 13 | |
13 | 14 | my ($tarball1, $tarball2); |
14 | 15 | my ($opt_list, $opt_modified, $opt_autoskip, $opt_stats); |
15 | | my $tempdir; |
| 16 | my $tempdir = tempdir( CLEANUP => 1 ); |
16 | 17 | |
17 | 18 | $SIG{'__DIE__'} = 'cleanup'; |
18 | 19 | $SIG{'TERM'} = 'cleanup'; |
… |
… |
|
173 | 174 | sub tardiff{ |
174 | 175 | my $error = 0; |
175 | 176 | |
176 | | $tempdir = "/tmp/tardiff-$$"; |
177 | | mkdir $tempdir; |
178 | | |
179 | 177 | my $filelist1 = untar($tarball1) or die "Error: Could not unpack $tarball1."; |
180 | 178 | my $filelist2 = untar($tarball2) or die "Error: Could not unpack $tarball2."; |
181 | 179 | |
… |
… |
|
216 | 214 | sub cleanup{ |
217 | 215 | my $handler = shift(@_); |
218 | 216 | |
219 | | if($tempdir){ |
220 | | system("rm -rf $tempdir"); |
221 | | } |
222 | | |
223 | 217 | if($handler eq "INT" or $handler eq "TERM"){ |
224 | 218 | exit 1; |
225 | 219 | } |