First, disable all the unsupported flags just to make sure they aren't
triggering something they shouldn't be. Also, zero the pglob struct
before passing to bsd_glob(); it contains function pointers, and it's
safest if they are null rather than containing random stack data.
Bug reported by Clément Lecigne <clemun@gmail.com>.
@EXPORT_OK = (@{$EXPORT_TAGS{'glob'}}, 'csh_glob');
-$VERSION = '1.12';
+$VERSION = '1.13';
sub import {
require Exporter;
/* 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);
} else if (ix) {
flags = (int) SvIV(get_sv("File::Glob::DEFAULT_FLAGS", GV_ADD));
}
/* call glob */
+ bzero(&pglob, sizeof(glob_t));
retval = bsd_glob(pattern, flags, errfunc, &pglob);
GLOB_ERROR = retval;
}
}
use strict;
-use Test::More tests => 14;
+use Test::More tests => 15;
BEGIN {use_ok('File::Glob', ':glob')};
use Cwd ();
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");