New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dup to closed filehandle creates file named GLOB(0x...) #14693
Comments
From knut.arne.bjorndal@easyconnect.noCreated by knut.arne.bjorndal@easyconnect.noThis is a bug report for perl from knut.arne.bjorndal@easyconnect.no, ----------------------------------------------------------------- close STDOUT; Expected result: die 'Bad file descriptor' What happened: A file named GLOB(0xe52b90) is created, and any output This has also been tested with 5.20.2 and 5.21.11 built with perlbrew. Perl Info
|
From @tonycozOn Wed May 06 04:03:02 2015, knut.arne.bjorndal@easyconnect.no wrote:
Try the attached patch. Tony |
From @tonycoz0001-perl-125115-don-t-create-file-GLOB-.-when-dupping-a-.patchFrom 39bf7e431534e42c3210ad15d03142b15e3e3207 Mon Sep 17 00:00:00 2001
From: Tony Cook <tony@develop-help.com>
Date: Thu, 7 May 2015 12:13:36 +1000
Subject: [PATCH] [perl #125115] don't create file GLOB(...) when dupping a
closed handle
This needs tests.
---
doio.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/doio.c b/doio.c
index 5f29a6b..2630252 100644
--- a/doio.c
+++ b/doio.c
@@ -438,8 +438,11 @@ Perl_do_open6(pTHX_ GV *gv, const char *oname, STRLEN len,
else if (IoTYPE(thatio) == IoTYPE_SOCKET)
IoTYPE(io) = IoTYPE_SOCKET;
}
- else
- wanted_fd = -1;
+ else {
+ SETERRNO(EBADF, RMS_IFI);
+ fp = NULL;
+ goto say_false;
+ }
}
if (!num_svs)
type = NULL;
--
1.7.10.4
|
The RT System itself - Status changed from 'new' to 'open' |
From knut.arne.bjorndal@easyconnect.noOn 07/05/15 04:14, Tony Cook via RT wrote:
Seems to work fine. I've tested both some isolated examples of this -- |
@tonycoz - Status changed from 'open' to 'deleted' |
@tonycoz - Status changed from 'deleted' to 'open' |
From @tonycozOn Thu May 07 09:02:04 2015, knut.arne.bjorndal@easyconnect.no wrote:
Thanks, I've attached a version with a test, which will go in once 5.22 is released. Tony |
From @tonycoz0001-perl-125115-don-t-create-file-GLOB-.-when-dupping-a-.patchFrom 6ca26df979d733f3c9eadca6141ee685955b9dad Mon Sep 17 00:00:00 2001
From: Tony Cook <tony@develop-help.com>
Date: Tue, 26 May 2015 16:03:31 +1000
Subject: [PATCH] [perl #125115] don't create file GLOB(...) when dupping a
closed handle
---
doio.c | 7 +++++--
t/io/open.t | 10 +++++++++-
2 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/doio.c b/doio.c
index 5f29a6b..2630252 100644
--- a/doio.c
+++ b/doio.c
@@ -438,8 +438,11 @@ Perl_do_open6(pTHX_ GV *gv, const char *oname, STRLEN len,
else if (IoTYPE(thatio) == IoTYPE_SOCKET)
IoTYPE(io) = IoTYPE_SOCKET;
}
- else
- wanted_fd = -1;
+ else {
+ SETERRNO(EBADF, RMS_IFI);
+ fp = NULL;
+ goto say_false;
+ }
}
if (!num_svs)
type = NULL;
diff --git a/t/io/open.t b/t/io/open.t
index 3817bdd..cffef14 100644
--- a/t/io/open.t
+++ b/t/io/open.t
@@ -10,7 +10,7 @@ $| = 1;
use warnings;
use Config;
-plan tests => 153;
+plan tests => 156;
my $Perl = which_perl();
@@ -476,6 +476,14 @@ pass("no crash when open autovivifies glob in freed package");
is((stat $temp)[9], $final_mtime, "nothing changes its mtime");
}
+# [perl #125115] Dup to closed filehandle creates file named GLOB(0x...)
+{
+ ok(open(my $fh, "<", "TEST"), "open a handle");
+ ok(close $fh, "and close it again");
+ ok(!open(my $fh2, ">&", $fh), "should fail to dup the closed handle");
+ # clean up if we failed
+ unlink "$fh";
+}
package OverloadTest;
use overload '""' => sub { ${$_[0]} };
--
1.7.10.4
|
@tonycoz - Status changed from 'open' to 'pending release' |
From @khwilliamsonThank you for submitting this report. You have helped make Perl better. Perl 5.24.0 may be downloaded via https://metacpan.org/release/RJBS/perl-5.24.0 |
@khwilliamson - Status changed from 'pending release' to 'resolved' |
Migrated from rt.perl.org#125115 (status was 'resolved')
Searchable as RT125115$
The text was updated successfully, but these errors were encountered: