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
17 DEBUG_u(PerlIO_printf(PerlIO_stderr(),
18 "%s %d %d %d\n", s, tainted, uid, euid));
22 ug = " while running setuid";
24 ug = " while running setgid";
26 ug = " while running with -T switch";
40 static char* misc_env[] = {
41 "IFS", /* most shells' inter-field separators */
42 "CDPATH", /* ksh dain bramage #1 */
43 "ENV", /* ksh dain bramage #2 */
44 "BASH_ENV", /* bash dain bramage -- I guess it's contagious */
50 char name[10 + TYPE_DIGITS(int)] = "DCL$PATH";
54 (void)sprintf(name,"DCL$PATH;%d", i);
55 svp = hv_fetch(GvHVn(envgv), name, strlen(name), FALSE);
56 if (!svp || *svp == &sv_undef)
58 if (SvTAINTED(*svp)) {
60 taint_proper("Insecure %s%s", "$ENV{DCL$PATH}");
62 if ((mg = mg_find(*svp, 'e')) && MgTAINTEDDIR(mg)) {
64 taint_proper("Insecure directory in %s%s", "$ENV{DCL$PATH}");
70 svp = hv_fetch(GvHVn(envgv),"PATH",4,FALSE);
72 if (SvTAINTED(*svp)) {
74 taint_proper("Insecure %s%s", "$ENV{PATH}");
76 if ((mg = mg_find(*svp, 'e')) && MgTAINTEDDIR(mg)) {
78 taint_proper("Insecure directory in %s%s", "$ENV{PATH}");
83 /* tainted $TERM is okay if it contains no metachars */
84 svp = hv_fetch(GvHVn(envgv),"TERM",4,FALSE);
85 if (svp && *svp && SvTAINTED(*svp)) {
86 bool was_tainted = tainted;
87 char *t = SvPV(*svp, na);
89 tainted = was_tainted;
90 if (t < e && isALNUM(*t))
92 while (t < e && (isALNUM(*t) || *t == '-' || *t == ':'))
96 taint_proper("Insecure $ENV{%s}%s", "TERM");
101 for (e = misc_env; *e; e++) {
102 svp = hv_fetch(GvHVn(envgv), *e, strlen(*e), FALSE);
103 if (svp && *svp != &sv_undef && SvTAINTED(*svp)) {
105 taint_proper("Insecure $ENV{%s}%s", *e);