2 * "...we will have peace, when you and all your works have perished--and
3 * the works of your dark master to whom you would deliver us. You are a
4 * liar, Saruman, and a corrupter of men's hearts." --Theoden
11 taint_proper(const char *f, char *s)
13 dTHR; /* just for taint */
16 DEBUG_u(PerlIO_printf(Perl_debug_log,
17 "%s %d %d %d\n", s, PL_tainted, PL_uid, PL_euid));
22 if (PL_euid != PL_uid)
23 ug = " while running setuid";
24 else if (PL_egid != PL_gid)
25 ug = " while running setgid";
27 ug = " while running with -T switch";
30 else if (ckWARN(WARN_TAINT))
31 warner(WARN_TAINT, f, s, ug);
41 static char* misc_env[] = {
42 "IFS", /* most shells' inter-field separators */
43 "CDPATH", /* ksh dain bramage #1 */
44 "ENV", /* ksh dain bramage #2 */
45 "BASH_ENV", /* bash dain bramage -- I guess it's contagious */
55 char name[10 + TYPE_DIGITS(int)] = "DCL$PATH";
59 (void)sprintf(name,"DCL$PATH;%d", i);
60 svp = hv_fetch(GvHVn(PL_envgv), name, strlen(name), FALSE);
61 if (!svp || *svp == &PL_sv_undef)
63 if (SvTAINTED(*svp)) {
66 taint_proper("Insecure %s%s", "$ENV{DCL$PATH}");
68 if ((mg = mg_find(*svp, 'e')) && MgTAINTEDDIR(mg)) {
71 taint_proper("Insecure directory in %s%s", "$ENV{DCL$PATH}");
78 svp = hv_fetch(GvHVn(PL_envgv),"PATH",4,FALSE);
80 if (SvTAINTED(*svp)) {
83 taint_proper("Insecure %s%s", "$ENV{PATH}");
85 if ((mg = mg_find(*svp, 'e')) && MgTAINTEDDIR(mg)) {
88 taint_proper("Insecure directory in %s%s", "$ENV{PATH}");
93 /* tainted $TERM is okay if it contains no metachars */
94 svp = hv_fetch(GvHVn(PL_envgv),"TERM",4,FALSE);
95 if (svp && *svp && SvTAINTED(*svp)) {
96 dTHR; /* just for taint */
98 bool was_tainted = PL_tainted;
99 char *t = SvPV(*svp, n_a);
101 PL_tainted = was_tainted;
102 if (t < e && isALNUM(*t))
104 while (t < e && (isALNUM(*t) || *t == '-' || *t == ':'))
108 taint_proper("Insecure $ENV{%s}%s", "TERM");
113 for (e = misc_env; *e; e++) {
114 svp = hv_fetch(GvHVn(PL_envgv), *e, strlen(*e), FALSE);
115 if (svp && *svp != &PL_sv_undef && SvTAINTED(*svp)) {
116 dTHR; /* just for taint */
118 taint_proper("Insecure $ENV{%s}%s", *e);