Change 30232 by [EMAIL PROTECTED] on 2007/02/12 16:27:14
Integrate:
[ 27184]
Back out change change 10214 (drop SVp_IOK from >> PRIVSHIFT) as it
never felt quite correct, and other parts of the SV conversion
implementation have improved such that the symptoms 10214 covered
over are gone even without it.
[ 27228]
To make arithmetic on tainted dualvars work properly requires that
sv_2nv uses SvIVX in preference to SvPVX, if SVp_IOK is true.
[ 29669]
Assignment to a tainted variable was causing confusion if the source
value was an NV too large for an IV (bug #40708). Fix the confusion
by not promoting private flags to public flags in S_save_magic if
there are already public flags.
Affected files ...
... //depot/maint-5.8/perl/mg.c#148 integrate
... //depot/maint-5.8/perl/scope.c#66 integrate
... //depot/maint-5.8/perl/sv.c#341 integrate
... //depot/maint-5.8/perl/t/op/taint.t#21 integrate
Differences ...
==== //depot/maint-5.8/perl/mg.c#148 (text) ====
Index: perl/mg.c
--- perl/mg.c#147~30163~ 2007-02-07 12:48:27.000000000 -0800
+++ perl/mg.c 2007-02-12 08:27:14.000000000 -0800
@@ -107,7 +107,10 @@
SvMAGICAL_off(sv);
SvREADONLY_off(sv);
- SvFLAGS(sv) |= (SvFLAGS(sv) & (SVp_NOK|SVp_POK)) >> PRIVSHIFT;
+ if (!(SvFLAGS(sv) & (SVf_IOK|SVf_NOK|SVf_POK))) {
+ /* No public flags are set, so promote any private flags to public. */
+ SvFLAGS(sv) |= (SvFLAGS(sv) & (SVp_IOK|SVp_NOK|SVp_POK)) >> PRIVSHIFT;
+ }
}
/*
==== //depot/maint-5.8/perl/scope.c#66 (text) ====
Index: perl/scope.c
--- perl/scope.c#65~30069~ 2007-01-29 13:05:26.000000000 -0800
+++ perl/scope.c 2007-02-12 08:27:14.000000000 -0800
@@ -208,7 +208,7 @@
if (SvGMAGICAL(osv)) {
const bool oldtainted = PL_tainted;
SvFLAGS(osv) |= (SvFLAGS(osv) &
- (SVp_NOK|SVp_POK)) >> PRIVSHIFT;
+ (SVp_IOK|SVp_NOK|SVp_POK)) >> PRIVSHIFT;
PL_tainted = oldtainted;
}
mg_localize(osv, sv);
==== //depot/maint-5.8/perl/sv.c#341 (text) ====
Index: perl/sv.c
--- perl/sv.c#340~30122~ 2007-02-04 14:37:19.000000000 -0800
+++ perl/sv.c 2007-02-12 08:27:14.000000000 -0800
@@ -2252,7 +2252,7 @@
mg_get(sv);
if (SvNOKp(sv))
return SvNVX(sv);
- if (SvPOKp(sv) && SvLEN(sv)) {
+ if ((SvPOKp(sv) && SvLEN(sv)) && !SvIOKp(sv)) {
if (!SvIOKp(sv) && ckWARN(WARN_NUMERIC) &&
!grok_number(SvPVX_const(sv), SvCUR(sv), NULL))
not_a_number(sv);
@@ -4284,7 +4284,7 @@
}
if (!SvMAGIC(sv)) {
SvMAGICAL_off(sv);
- SvFLAGS(sv) |= (SvFLAGS(sv) & (SVp_NOK|SVp_POK)) >> PRIVSHIFT;
+ SvFLAGS(sv) |= (SvFLAGS(sv) & (SVp_IOK|SVp_NOK|SVp_POK)) >> PRIVSHIFT;
}
return 0;
==== //depot/maint-5.8/perl/t/op/taint.t#21 (xtext) ====
Index: perl/t/op/taint.t
--- perl/t/op/taint.t#20~30173~ 2007-02-08 06:22:18.000000000 -0800
+++ perl/t/op/taint.t 2007-02-12 08:27:14.000000000 -0800
@@ -17,7 +17,7 @@
use File::Spec::Functions;
BEGIN { require './test.pl'; }
-plan tests => 252;
+plan tests => 255;
$| = 1;
@@ -1184,3 +1184,25 @@
eval 'eval $tainted';
like ($@, qr/^Insecure dependency in eval/);
}
+
+SKIP:
+{
+ my $got_dualvar;
+ eval 'use Scalar::Util "dualvar"; $got_dualvar++';
+ skip "No Scalar::Util::dualvar" unless $got_dualvar;
+ my $a = Scalar::Util::dualvar(3, $^X);
+ my $b = $a + 5;
+ is ($b, 8, "Arithmetic on tainted dualvars works");
+}
+
+{
+ # 40708
+ my $n = 7e9;
+ 8e9 - $n;
+
+ my $val = $n;
+ is ($val, '7000000000', 'Assignment to untainted variable');
+ $val = $TAINT;
+ $val = $n;
+ is ($val, '7000000000', 'Assignment to tainted variable');
+}
End of Patch.