Re: DBD::Sybase and Sybase::CTlib build problems w/ 5.8.1, Solaris, gcc
[p5sagit/p5-mst-13.2.git] / taint.c
diff --git a/taint.c b/taint.c
index c25ff77..c591e3f 100644 (file)
--- a/taint.c
+++ b/taint.c
@@ -1,3 +1,13 @@
+/*    taint.c
+ *
+ *    Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+ *    2000, 2001, 2002, by Larry Wall and others
+ *
+ *    You may distribute under the terms of either the GNU General Public
+ *    License or the Artistic License, as specified in the README file.
+ *
+ */
+
 /*
  * "...we will have peace, when you and all your works have perished--and
  * the works of your dark master to whom you would deliver us.  You are a
@@ -48,7 +58,7 @@ Perl_taint_proper(pTHX_ const char *f, const char *s)
            ug = " while running with -T switch";
        if (PL_unsafe || PL_taint_warn) {
             if(ckWARN(WARN_TAINT))
-                Perl_warner(aTHX_ WARN_TAINT, f, s, ug);
+                Perl_warner(aTHX_ packWARN(WARN_TAINT), f, s, ug);
         }
         else {
             Perl_croak(aTHX_ f, s, ug);
@@ -70,7 +80,8 @@ Perl_taint_env(pTHX)
        NULL
     };
 
-    if (!PL_envgv)
+    /* Don't bother if there's no %ENV hash */
+    if (!PL_envgv || !GvHV(PL_envgv))
        return;
 
 #ifdef VMS
@@ -88,7 +99,9 @@ Perl_taint_env(pTHX)
            TAINT;
            taint_proper("Insecure %s%s", "$ENV{DCL$PATH}");
        }
-       if ((mg = mg_find(*svp, PERL_MAGIC_envelem)) && MgTAINTEDDIR(mg)) {
+       if (SvMAGICAL(*svp)
+               && (mg = mg_find(*svp, PERL_MAGIC_envelem))
+               && MgTAINTEDDIR(mg)) {
            TAINT;
            taint_proper("Insecure directory in %s%s", "$ENV{DCL$PATH}");
        }
@@ -103,7 +116,9 @@ Perl_taint_env(pTHX)
            TAINT;
            taint_proper("Insecure %s%s", "$ENV{PATH}");
        }
-       if ((mg = mg_find(*svp, PERL_MAGIC_envelem)) && MgTAINTEDDIR(mg)) {
+       if (SvMAGICAL(*svp)
+               && (mg = mg_find(*svp, PERL_MAGIC_envelem))
+               && MgTAINTEDDIR(mg)) {
            TAINT;
            taint_proper("Insecure directory in %s%s", "$ENV{PATH}");
        }
@@ -120,7 +135,7 @@ Perl_taint_env(pTHX)
        PL_tainted = was_tainted;
        if (t < e && isALNUM(*t))
            t++;
-       while (t < e && (isALNUM(*t) || *t == '-' || *t == ':'))
+       while (t < e && (isALNUM(*t) || strchr("-_.+", *t)))
            t++;
        if (t < e) {
            TAINT;