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)) {
60 taint_proper("Insecure %s%s", "$ENV{DCL$PATH}");
62 if ((mg = mg_find(*svp, 'e')) && MgTAINTEDDIR(mg)) {
65 taint_proper("Insecure directory in %s%s", "$ENV{DCL$PATH}");
71 svp = hv_fetch(GvHVn(envgv),"PATH",4,FALSE);
73 if (SvTAINTED(*svp)) {
76 taint_proper("Insecure %s%s", "$ENV{PATH}");
78 if ((mg = mg_find(*svp, 'e')) && MgTAINTEDDIR(mg)) {
81 taint_proper("Insecure directory in %s%s", "$ENV{PATH}");
86 /* tainted $TERM is okay if it contains no metachars */
87 svp = hv_fetch(GvHVn(envgv),"TERM",4,FALSE);
88 if (svp && *svp && SvTAINTED(*svp)) {
89 dTHR; /* just for taint */
90 bool was_tainted = tainted;
91 char *t = SvPV(*svp, na);
93 tainted = was_tainted;
94 if (t < e && isALNUM(*t))
96 while (t < e && (isALNUM(*t) || *t == '-' || *t == ':'))
100 taint_proper("Insecure $ENV{%s}%s", "TERM");
105 for (e = misc_env; *e; e++) {
106 svp = hv_fetch(GvHVn(envgv), *e, strlen(*e), FALSE);
107 if (svp && *svp != &sv_undef && SvTAINTED(*svp)) {
108 dTHR; /* just for taint */
110 taint_proper("Insecure $ENV{%s}%s", *e);