develooper Front page | perl.perl5.porters | Postings from December 2008

Re: taint copying (was Re: 5.8.9/taint/NYTProf regression)

Thread Previous
From:
Rick Delaney
Date:
December 2, 2008 08:25
Subject:
Re: taint copying (was Re: 5.8.9/taint/NYTProf regression)
Message ID:
20081202162532.GK28006@bort.ca
On Dec 01 2008, Chip Salzenberg wrote:
> On Mon, Dec 01, 2008 at 11:52:03PM -0500, Rick Delaney wrote:
> > diff -pruNb perl-5.8.x/scope.c perl-5.8.9-RC1/scope.c
> > --- perl-5.8.x/scope.c	2008-10-29 04:23:15.000000000 -0400
> > +++ perl-5.8.9-RC1/scope.c	2008-12-01 23:27:07.000000000 -0500
> > @@ -621,12 +621,17 @@ Perl_leave_scope(pTHX_ I32 base)
> >  	const int type = SSPOPINT;
> >  	switch (type) {
> >  	case SAVEt_ITEM:			/* normal string */
> > +	    {
> > +		bool was_tainted = 0;
> >  	    value = (SV*)SSPOPPTR;
> >  	    sv = (SV*)SSPOPPTR;
> > +		was_tainted = SvTAINTED(value);
> >  	    sv_replace(sv,value);
> > +		was_tainted ? SvTAINTED_on(sv) : SvTAINTED_off(sv);
> >  	    PL_localizing = 2;
> >  	    SvSETMAGIC(sv);
> >  	    PL_localizing = 0;
> > +	    }
> >  	    break;
> >  	case SAVEt_SV:				/* scalar reference */
> >  	    value = (SV*)SSPOPPTR;
> 
> Since SvSETMAGIC() could set or clear the taint flag, perhaps any manual
> manipulation of that flag go _after_ the SvSETMAGIC?

Good point, although in this case magic_settaint() will never even get
called because PL_localizing is 2 (see mg_set()).  Not sure if we have
a regression test for this, though, or how to even write one.

-- 
Rick Delaney
rick@bort.ca

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About