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 */
54 char name[10 + TYPE_DIGITS(int)] = "DCL$PATH";
58 (void)sprintf(name,"DCL$PATH;%d", i);
59 svp = hv_fetch(GvHVn(PL_envgv), name, strlen(name), FALSE);
60 if (!svp || *svp == &PL_sv_undef)
62 if (SvTAINTED(*svp)) {
65 taint_proper("Insecure %s%s", "$ENV{DCL$PATH}");
67 if ((mg = mg_find(*svp, 'e')) && MgTAINTEDDIR(mg)) {
70 taint_proper("Insecure directory in %s%s", "$ENV{DCL$PATH}");
76 svp = hv_fetch(GvHVn(PL_envgv),"PATH",4,FALSE);
78 if (SvTAINTED(*svp)) {
81 taint_proper("Insecure %s%s", "$ENV{PATH}");
83 if ((mg = mg_find(*svp, 'e')) && MgTAINTEDDIR(mg)) {
86 taint_proper("Insecure directory in %s%s", "$ENV{PATH}");
91 /* tainted $TERM is okay if it contains no metachars */
92 svp = hv_fetch(GvHVn(PL_envgv),"TERM",4,FALSE);
93 if (svp && *svp && SvTAINTED(*svp)) {
94 dTHR; /* just for taint */
96 bool was_tainted = PL_tainted;
97 char *t = SvPV(*svp, n_a);
99 PL_tainted = was_tainted;
100 if (t < e && isALNUM(*t))
102 while (t < e && (isALNUM(*t) || *t == '-' || *t == ':'))
106 taint_proper("Insecure $ENV{%s}%s", "TERM");
111 for (e = misc_env; *e; e++) {
112 svp = hv_fetch(GvHVn(PL_envgv), *e, strlen(*e), FALSE);
113 if (svp && *svp != &PL_sv_undef && SvTAINTED(*svp)) {
114 dTHR; /* just for taint */
116 taint_proper("Insecure $ENV{%s}%s", *e);