From: David Mitchell Date: Mon, 11 Jan 2010 21:42:07 +0000 (+0000) Subject: fix for [perl #61976] Errno ($!) not evaluated to a error message string X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=0097b436152452e403cc71b4f1a1cfd30ec0ba1a;p=p5sagit%2Fp5-mst-13.2.git fix for [perl #61976] Errno ($!) not evaluated to a error message string (5.10.0 in taint mode) Change 27176 / 2a509ed3c095f7d712013e653f68821f6bb2d6db fixed a taint bug, which as a side effect, meant that $! used within a tainted expression failed to have a string value. This quick fix just makes sure the POK flag is set (prior to it being shifted back to pPOK). --- diff --git a/mg.c b/mg.c index fb91325..ddfc2ff 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 796b6fa..161073d 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};