summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mg.c1
-rw-r--r--t/op/taint.t13
2 files changed, 13 insertions, 1 deletions
diff --git a/mg.c b/mg.c
index fb913259fd..ddfc2ff2fa 100644
--- a/mg.c
+++ b/mg.c
@@ -1048,6 +1048,7 @@ Perl_magic_get(pTHX_ SV *sv, MAGIC *mg)
else
#endif
sv_setpv(sv, errno ? Strerror(errno) : "");
+ SvPOK_on(sv); /* may have got removed during taint processing */
RESTORE_ERRNO;
}
#endif
diff --git a/t/op/taint.t b/t/op/taint.t
index 796b6fab47..161073deb6 100644
--- a/t/op/taint.t
+++ b/t/op/taint.t
@@ -17,7 +17,7 @@ use Config;
use File::Spec::Functions;
BEGIN { require './test.pl'; }
-plan tests => 301;
+plan tests => 302;
$| = 1;
@@ -1308,6 +1308,17 @@ foreach my $ord (78, 163, 256) {
ok(tainted($zz), "pack a*a* preserves tainting");
}
+# Bug RT #61976 tainted $! would show numeric rather than string value
+
+{
+ my $tainted_path = substr($^X,0,0) . "/no/such/file";
+ my $err;
+ # $! is used in a tainted expression, so gets tainted
+ open my $fh, $tainted_path or $err= "$!";
+ unlike($err, qr/^\d+$/, 'tainted $!');
+}
+
+
# This may bomb out with the alarm signal so keep it last
SKIP: {
skip "No alarm()" unless $Config{d_alarm};