Ticket #51292: patch-CVE-2015-0858.diff

File patch-CVE-2015-0858.diff, 1.4 KB (added by raimue (Rainer Müller), 8 years ago)
  • tardiff

    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
    
     
    77
    88use strict;
    99use Text::Diff;
     10use File::Temp qw(tempdir);
    1011
    1112my $VERSION = '0.1';
    1213
    1314my ($tarball1, $tarball2);
    1415my ($opt_list, $opt_modified, $opt_autoskip, $opt_stats);
    15 my $tempdir;
     16my $tempdir = tempdir( CLEANUP => 1 );
    1617
    1718$SIG{'__DIE__'} = 'cleanup';
    1819$SIG{'TERM'} = 'cleanup';
     
    173174sub tardiff{
    174175        my $error = 0;
    175176
    176         $tempdir = "/tmp/tardiff-$$";
    177         mkdir $tempdir;
    178 
    179177        my $filelist1 = untar($tarball1) or die "Error: Could not unpack $tarball1.";
    180178        my $filelist2 = untar($tarball2) or die "Error: Could not unpack $tarball2.";
    181179
     
    216214sub cleanup{
    217215        my $handler = shift(@_);
    218216
    219         if($tempdir){
    220                 system("rm -rf $tempdir");
    221         }
    222 
    223217        if($handler eq "INT" or $handler eq "TERM"){
    224218                exit 1;
    225219        }