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, tainted, uid, euid));
21 ug = " while running setuid";
23 ug = " while running setgid";
25 ug = " while running with -T switch";
39 static char* misc_env[] = {
40 "IFS", /* most shells' inter-field separators */
41 "CDPATH", /* ksh dain bramage #1 */
42 "ENV", /* ksh dain bramage #2 */
43 "BASH_ENV", /* bash dain bramage -- I guess it's contagious */
49 char name[10 + TYPE_DIGITS(int)] = "DCL$PATH";
53 (void)sprintf(name,"DCL$PATH;%d", i);
54 svp = hv_fetch(GvHVn(envgv), name, strlen(name), FALSE);
55 if (!svp || *svp == &sv_undef)
57 if (SvTAINTED(*svp)) {
59 taint_proper("Insecure %s%s", "$ENV{DCL$PATH}");
61 if ((mg = mg_find(*svp, 'e')) && MgTAINTEDDIR(mg)) {
63 taint_proper("Insecure directory in %s%s", "$ENV{DCL$PATH}");
69 svp = hv_fetch(GvHVn(envgv),"PATH",4,FALSE);
71 if (SvTAINTED(*svp)) {
74 taint_proper("Insecure %s%s", "$ENV{PATH}");
76 if ((mg = mg_find(*svp, 'e')) && MgTAINTEDDIR(mg)) {
79 taint_proper("Insecure directory in %s%s", "$ENV{PATH}");
84 /* tainted $TERM is okay if it contains no metachars */
85 svp = hv_fetch(GvHVn(envgv),"TERM",4,FALSE);
86 if (svp && *svp && SvTAINTED(*svp)) {
87 dTHR; /* just for taint */
88 bool was_tainted = tainted;
89 char *t = SvPV(*svp, na);
91 tainted = was_tainted;
92 if (t < e && isALNUM(*t))
94 while (t < e && (isALNUM(*t) || *t == '-' || *t == ':'))
98 taint_proper("Insecure $ENV{%s}%s", "TERM");
103 for (e = misc_env; *e; e++) {
104 svp = hv_fetch(GvHVn(envgv), *e, strlen(*e), FALSE);
105 if (svp && *svp != &sv_undef && SvTAINTED(*svp)) {
106 dTHR; /* just for taint */
108 taint_proper("Insecure $ENV{%s}%s", *e);