develooper Front page | perl.perl5.porters | Postings from March 2003

[patch] PL_taint_warn falls between chairs in perl_clone()

From:
Stas Bekman
Date:
March 10, 2003 22:10
Subject:
[patch] PL_taint_warn falls between chairs in perl_clone()
Message ID:
3E6D7D7E.5000704@stason.org
I was wondering why do I get ${^TAINT} reporting -1 with -T only, under 
threaded mod_perl 2.0. Figured it out, that PL_taint_warn had a garbage data 
after perl_clone(). Here is the patch (attached as well because of those pesky 
tabs :( ):

(I guess we need to add a reminder to intrpvar.h to make sure that when new 
state vars are added they aren't forgotten to be added to the perl_clone() 
function)

--- sv.c.orig	2003-03-11 17:00:53.000000000 +1100
+++ sv.c	2003-03-11 17:01:10.000000000 +1100
@@ -10802,6 +10802,7 @@

      /* internal state */
      PL_tainting		= proto_perl->Itainting;
+    PL_taint_warn       = proto_perl->Itaint_warn;
      PL_maxo		= proto_perl->Imaxo;
      if (proto_perl->Iop_mask)
  	PL_op_mask	= SAVEPVN(proto_perl->Iop_mask, PL_maxo);

Here is the test program that should print 1, 1 but prints 1, -1:

#include <EXTERN.h>
#include <perl.h>

/* we're going to embed two interpreters */
/* build: gcc -o taint taint.c `perl-blead-ithreads  -MExtUtils::Embed -e 
ccopts -e ldopts` -Wall -g */

#define LOAD ""
#define TEST "print ${^TAINT}"

int main(int argc, char **argv, char **env)
{
     char *embedding[] = { "", "-lTe", "0" };
     dTHX;
     PerlInterpreter *one_perl = perl_alloc();
     PerlInterpreter *two_perl;

     aTHX = one_perl; PERL_SET_CONTEXT(aTHX);
     perl_construct(one_perl);

     perl_parse(one_perl, NULL, 3, embedding, (char **)NULL);

     eval_pv(LOAD, TRUE); /* loaded only by the first perl */

     two_perl = perl_clone(one_perl, CLONEf_KEEP_PTR_TABLE);

     eval_pv(TEST, TRUE);

     aTHX = two_perl; PERL_SET_CONTEXT(aTHX);
     eval_pv(TEST, TRUE);

     //gdb> print my_perl->Itaint_warn
     //$1 = -85 '«'

     perl_destruct(two_perl);
     perl_free(two_perl);

     perl_destruct(one_perl);
     perl_free(one_perl);

     exit(0);

}


__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com



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