diff options
author | Rafael Garcia-Suarez <rgarciasuarez@mandriva.org> | 2005-11-15 16:22:42 +0000 |
---|---|---|
committer | Rafael Garcia-Suarez <rgarciasuarez@mandriva.org> | 2005-11-15 16:22:42 +0000 |
commit | dc628f74c42ec458b6de48577d2a3f361d3c34c2 (patch) | |
tree | 4f7627721caadbf4b86a90c732ad653b8f5d35af | |
parent | 06a335b68dc2cf67704e9b9367e9b7a256eebd8e (diff) | |
download | perl-MDK-Common-dc628f74c42ec458b6de48577d2a3f361d3c34c2.tar perl-MDK-Common-dc628f74c42ec458b6de48577d2a3f361d3c34c2.tar.gz perl-MDK-Common-dc628f74c42ec458b6de48577d2a3f361d3c34c2.tar.bz2 perl-MDK-Common-dc628f74c42ec458b6de48577d2a3f361d3c34c2.tar.xz perl-MDK-Common-dc628f74c42ec458b6de48577d2a3f361d3c34c2.zip |
Use 3-arg open to avoid potential security risk with magical opens
-rw-r--r-- | MDK/Common/File.pm | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/MDK/Common/File.pm b/MDK/Common/File.pm index 661ddc3..1924931 100644 --- a/MDK/Common/File.pm +++ b/MDK/Common/File.pm @@ -132,8 +132,8 @@ our %EXPORT_TAGS = (all => [ @EXPORT_OK ]); sub dirname { local $_ = shift; s|[^/]*/*\s*$||; s|(.)/*$|$1|; $_ || '.' } sub basename { local $_ = shift; s|/*\s*$||; s|.*/||; $_ } -sub cat_ { my @l = map { my $F; open($F, $_) ? <$F> : () } @_; wantarray() ? @l : join '', @l } -sub cat_or_die { open(my $F, $_[0]) or die "can't read file $_[0]: $!\n"; my @l = <$F>; wantarray() ? @l : join '', @l } +sub cat_ { my @l = map { my $F; open($F, '<', $_) ? <$F> : () } @_; wantarray() ? @l : join '', @l } +sub cat_or_die { open(my $F, '<', $_[0]) or die "can't read file $_[0]: $!\n"; my @l = <$F>; wantarray() ? @l : join '', @l } sub cat__ { my ($f) = @_; my @l = <$f>; wantarray() ? @l : join '', @l } sub output { my $f = shift; open(my $F, ">$f") or die "output in file $f failed: $!\n"; print $F $_ foreach @_; 1 } sub append_to_file { my $f = shift; open(my $F, ">>$f") or die "output in file $f failed: $!\n"; print $F $_ foreach @_; 1 } |