X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=taint.c;h=584c9f48fe100f24ef02d78fb4c778a8809d7f80;hb=d83e6520878f26ddb2592ab5b8b67eb482e51ea6;hp=dbb0a1e9dc82e117b8b8403ae34cc57906bdd499;hpb=71be2cbc73608e37e1a2ab7e459a02111137d1b0;p=p5sagit%2Fp5-mst-13.2.git diff --git a/taint.c b/taint.c index dbb0a1e..584c9f4 100644 --- a/taint.c +++ b/taint.c @@ -14,9 +14,10 @@ char *s; { char *ug; + DEBUG_u(PerlIO_printf(PerlIO_stderr(), + "%s %d %d %d\n", s, tainted, uid, euid)); + if (tainted) { - DEBUG_u(PerlIO_printf(PerlIO_stderr(), - "%s %d %d %d\n", s, tainted, uid, euid)); if (euid != uid) ug = " while running setuid"; else if (egid != gid) @@ -34,23 +35,44 @@ void taint_env() { SV** svp; - MAGIC *mg = 0; + MAGIC *mg; + +#ifdef VMS + int i = 0; + char name[14] = "DCL$PATH"; + + while (1) { + if (i) + (void)sprintf(name,"DCL$PATH;%d", i); + svp = hv_fetch(GvHVn(envgv), name, strlen(name), FALSE); + if (!svp || *svp == &sv_undef) + break; + if (SvTAINTED(*svp)) { + TAINT; + taint_proper("Insecure %s%s", "$ENV{DCL$PATH}"); + } + if ((mg = mg_find(*svp, 'e')) && MgTAINTEDDIR(mg)) { + TAINT; + taint_proper("Insecure directory in %s%s", "$ENV{DCL$PATH}"); + } + i++; + } +#endif /* VMS */ svp = hv_fetch(GvHVn(envgv),"PATH",4,FALSE); - if (!svp || *svp == &sv_undef || - ((mg = mg_find(*svp, 't')) && mg->mg_len & 1)) - { - TAINT; - if (mg && MgTAINTEDDIR(mg)) - taint_proper("Insecure directory in %s%s", "$ENV{PATH}"); - else + if (svp && *svp) { + if (SvTAINTED(*svp)) { + TAINT; taint_proper("Insecure %s%s", "$ENV{PATH}"); + } + if ((mg = mg_find(*svp, 'e')) && MgTAINTEDDIR(mg)) { + TAINT; + taint_proper("Insecure directory in %s%s", "$ENV{PATH}"); + } } svp = hv_fetch(GvHVn(envgv),"IFS",3,FALSE); - if (svp && *svp != &sv_undef && - (mg = mg_find(*svp, 't')) && mg->mg_len & 1) - { + if (svp && *svp != &sv_undef && SvTAINTED(*svp)) { TAINT; taint_proper("Insecure %s%s", "$ENV{IFS}"); }