#
# CVE-2011-2728
# http://perl5.git.perl.org/perl.git/commit/1af4051e077438976a4c12a0622feaf6715bec77
# https://bugzilla.redhat.com/show_bug.cgi?id=742236
#
diff -urN perl-5.12.3/ext/File-Glob/Glob.xs p/ext/File-Glob/Glob.xs
--- perl-5.12.3/ext/File-Glob/Glob.xs 2011-01-09 12:20:55.000000000 -0800
+++ perl-5.12.3/ext/File-Glob/Glob.xs 2011-11-28 00:46:10.593556922 -0800
@@ -1,6 +1,7 @@
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
+#include "strings.h"
#include "bsd_glob.h"
@@ -49,9 +50,12 @@
/* allow for optional flags argument */
if (items > 1) {
flags = (int) SvIV(ST(1));
+ /* remove unsupported flags */
+ flags &= ~(GLOB_APPEND | GLOB_DOOFFS | GLOB_ALTDIRFUNC | GLOB_MAGCHAR);
}
/* call glob */
+ bzero(&pglob, sizeof(glob_t));
retval = bsd_glob(pattern, flags, errfunc, &pglob);
GLOB_ERROR = retval;
--- perl-5.12.3/ext/File-Glob/t/basic.t.orig út lis 15 13:22:27 2011
+++ perl-5.12.3/ext/File-Glob/t/basic.t út lis 15 13:22:54 2011
@@ -15,7 +15,7 @@
}
}
use strict;
-use Test::More tests => 14;
+use Test::More tests => 15;
BEGIN {use_ok('File::Glob', ':glob')};
use Cwd ();
@@ -195,3 +195,7 @@
local $TODO = "home-made glob doesn't do regexes" if $^O eq 'VMS';
is_deeply(\@glob_files, ['a_dej']);
}
+
+# This used to segfault.
+my $i = bsd_glob('*', GLOB_ALTDIRFUNC);
+is(&File::Glob::GLOB_ERROR, 0, "Successfuly ignored unsupported flag");