Change 19863 by [EMAIL PROTECTED] on 2003/06/27 08:15:11

        Introduce (global) variable PL_earlytaint which
        is set very early in main(), before perl_parse()
        has been called and PL_tainting (or PL_taint_warn)
        might have been set.

Affected files ...

... //depot/perl/embed.fnc#90 edit
... //depot/perl/embedvar.h#172 edit
... //depot/perl/miniperlmain.c#38 edit
... //depot/perl/perl.c#491 edit
... //depot/perl/perl.h#515 edit
... //depot/perl/perlapi.h#94 edit
... //depot/perl/perlvars.h#53 edit
... //depot/perl/proto.h#447 edit

Differences ...

==== //depot/perl/embed.fnc#90 (text) ====
Index: perl/embed.fnc
--- perl/embed.fnc#89~19862~    Fri Jun 27 00:39:58 2003
+++ perl/embed.fnc      Fri Jun 27 01:15:11 2003
@@ -45,7 +45,7 @@
 Anod   |int    |perl_run       |PerlInterpreter* interp
 Anod   |int    |perl_parse     |PerlInterpreter* interp|XSINIT_t xsinit \
                                |int argc|char** argv|char** env
-np     |int    |doing_taint    |int argc|char** argv|char** env
+np     |bool   |doing_taint    |int argc|char** argv|char** env
 #if defined(USE_ITHREADS)
 Anod   |PerlInterpreter*|perl_clone|PerlInterpreter* interp, UV flags
 #  if defined(PERL_IMPLICIT_SYS)

==== //depot/perl/embedvar.h#172 (text+w) ====
Index: perl/embedvar.h
--- perl/embedvar.h#171~19854~  Wed Jun 25 22:32:02 2003
+++ perl/embedvar.h     Fri Jun 27 01:15:11 2003
@@ -897,6 +897,7 @@
 #define PL_curinterp           (PL_Vars.Gcurinterp)
 #define PL_do_undump           (PL_Vars.Gdo_undump)
 #define PL_dollarzero_mutex    (PL_Vars.Gdollarzero_mutex)
+#define PL_earlytaint          (PL_Vars.Gearlytaint)
 #define PL_hexdigit            (PL_Vars.Ghexdigit)
 #define PL_malloc_mutex                (PL_Vars.Gmalloc_mutex)
 #define PL_op_mutex            (PL_Vars.Gop_mutex)
@@ -911,6 +912,7 @@
 #define PL_Gcurinterp          PL_curinterp
 #define PL_Gdo_undump          PL_do_undump
 #define PL_Gdollarzero_mutex   PL_dollarzero_mutex
+#define PL_Gearlytaint         PL_earlytaint
 #define PL_Ghexdigit           PL_hexdigit
 #define PL_Gmalloc_mutex       PL_malloc_mutex
 #define PL_Gop_mutex           PL_op_mutex

==== //depot/perl/miniperlmain.c#38 (text) ====
Index: perl/miniperlmain.c
--- perl/miniperlmain.c#37~19242~       Wed Apr 16 13:14:01 2003
+++ perl/miniperlmain.c Fri Jun 27 01:15:11 2003
@@ -56,6 +56,9 @@
     /* noop unless Configure is given -Accflags=-DPERL_GPROF_CONTROL */
     PERL_GPROF_MONCONTROL(0);
 
+    /* To be used instead PL_taining before perl_parse() */
+    PL_earlytaint = doing_taint(argc, argv, env);
+
     PERL_SYS_INIT3(&argc,&argv,&env);
 
 #if defined(USE_ITHREADS)

==== //depot/perl/perl.c#491 (text) ====
Index: perl/perl.c
--- perl/perl.c#490~19862~      Fri Jun 27 00:39:58 2003
+++ perl/perl.c Fri Jun 27 01:15:11 2003
@@ -154,7 +154,6 @@
    if (PL_perl_destruct_level > 0)
        init_interp();
 #endif
-
    /* Init the real globals (and main thread)? */
     if (!PL_linestr) {
 #ifdef PERL_FLEXIBLE_EXCEPTIONS
@@ -3329,24 +3328,25 @@
 
 /* This is used very early in the lifetime of the program,
  * before even the options are parsed, so PL_tainting has
- * not been initialized properly.*/
-int
+ * not been initialized properly.  The variable PL_earlytaint
+ * is set early in main() to the result of this function. */
+bool
 Perl_doing_taint(int argc, char *argv[], char *envp[])
 {
-    int uid = PerlProc_getuid();
+    int uid  = PerlProc_getuid();
     int euid = PerlProc_geteuid();
-    int gid = PerlProc_getgid();
+    int gid  = PerlProc_getgid();
     int egid = PerlProc_getegid();
 
 #ifdef VMS
-    uid |= gid << 16;
+    uid  |=  gid << 16;
     euid |= egid << 16;
 #endif
     if (uid && (euid != uid || egid != gid))
        return 1;
-    /* This is a really primitive check; $ENV{PERL_MALLOC_OPT} is
-       ignored only if -T are the first chars together; otherwise one
-       gets "Too late" message. */
+    /* This is a really primitive check; environment gets ignored only
+     * if -T are the first chars together; otherwise one gets
+     *  "Too late" message. */
     if ( argc > 1 && argv[1][0] == '-'
          && (argv[1][1] == 't' || argv[1][1] == 'T') )
        return 1;

==== //depot/perl/perl.h#515 (text) ====
Index: perl/perl.h
--- perl/perl.h#514~19854~      Wed Jun 25 22:32:02 2003
+++ perl/perl.h Fri Jun 27 01:15:11 2003
@@ -498,9 +498,8 @@
                if (newval) {                                   \
                  panic_write2("panic: tainting with $ENV{PERL_MALLOC_OPT}\n");\
                  exit(1); })
-extern int Perl_doing_taint(int argc, char *argv[], char *envp[]);
 #  define MALLOC_CHECK_TAINT(argc,argv,env)    STMT_START {    \
-       if (Perl_doing_taint(argc, argv, env))  {               \
+       if (Perl_doing_taint(argc,argv,env)) {                  \
                MallocCfg_ptr[MallocCfg_skip_cfg_env] = 1;      \
     }} STMT_END;
 #else  /* MYMALLOC */

==== //depot/perl/perlapi.h#94 (text+w) ====
Index: perl/perlapi.h
--- perl/perlapi.h#93~19854~    Wed Jun 25 22:32:02 2003
+++ perl/perlapi.h      Fri Jun 27 01:15:11 2003
@@ -934,6 +934,8 @@
 #define PL_do_undump           (*Perl_Gdo_undump_ptr(NULL))
 #undef  PL_dollarzero_mutex
 #define PL_dollarzero_mutex    (*Perl_Gdollarzero_mutex_ptr(NULL))
+#undef  PL_earlytaint
+#define PL_earlytaint          (*Perl_Gearlytaint_ptr(NULL))
 #undef  PL_hexdigit
 #define PL_hexdigit            (*Perl_Ghexdigit_ptr(NULL))
 #undef  PL_malloc_mutex

==== //depot/perl/perlvars.h#53 (text) ====
Index: perl/perlvars.h
--- perl/perlvars.h#52~19499~   Sun May 11 21:49:57 2003
+++ perl/perlvars.h     Fri Jun 27 01:15:11 2003
@@ -54,3 +54,6 @@
 
 /* This is constant on most architectures, a global on OS/2 */
 PERLVARI(Gsh_path,     char *, SH_PATH)/* full path of shell */
+
+PERLVAR(Gearlytaint,   bool)   /* Early warning for taint, before PL_tainting  is set 
*/
+

==== //depot/perl/proto.h#447 (text+w) ====
Index: perl/proto.h
--- perl/proto.h#446~19862~     Fri Jun 27 00:39:58 2003
+++ perl/proto.h        Fri Jun 27 01:15:11 2003
@@ -26,7 +26,7 @@
 PERL_CALLCONV void     perl_free(PerlInterpreter* interp);
 PERL_CALLCONV int      perl_run(PerlInterpreter* interp);
 PERL_CALLCONV int      perl_parse(PerlInterpreter* interp, XSINIT_t xsinit, int argc, 
char** argv, char** env);
-PERL_CALLCONV int      Perl_doing_taint(int argc, char** argv, char** env);
+PERL_CALLCONV bool     Perl_doing_taint(int argc, char** argv, char** env);
 #if defined(USE_ITHREADS)
 PERL_CALLCONV PerlInterpreter* perl_clone(PerlInterpreter* interp, UV flags);
 #  if defined(PERL_IMPLICIT_SYS)
End of Patch.

Reply via email to