Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 140 lines (126 sloc) 3.212 kb
a0d0e21e »
1994-10-17 perl 5.000
1 /*
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
5 */
6
463ee0b2 »
1993-11-10 perl 5.0 alpha 4
7 #include "EXTERN.h"
864dbfa3 »
1999-06-07 initial stub implementation of implicit thread/this
8 #define PERL_IN_TAINT_C
463ee0b2 »
1993-11-10 perl 5.0 alpha 4
9 #include "perl.h"
10
11 void
dff6d3cd »
1999-10-26 warnings and const violations identified by compiling in C++ mode
12 Perl_taint_proper(pTHX_ const char *f, const char *s)
79072805 »
1993-10-07 perl 5.0 alpha 2
13 {
bbce6d69 »
1996-11-26 [inseparable changes from patch from perl5.003_08 to perl5.003_09]
14 char *ug;
15
26e623cf »
2001-12-24 Promote the e/uid to wide enough un/signed integers
16 #if defined(HAS_SETEUID) && defined(DEBUGGING)
17 # if Uid_t_size == 1
18 {
19 UV uid = PL_uid;
20 UV euid = PL_euid;
21
22 DEBUG_u(PerlIO_printf(Perl_debug_log,
23 "%s %d %"UVuf" %"UVuf"\n",
24 s, PL_tainted, uid, euid));
25 }
26 # else
27 {
28 IV uid = PL_uid;
29 IV euid = PL_euid;
30
31 DEBUG_u(PerlIO_printf(Perl_debug_log,
32 "%s %d %"IVdf" %"IVdf"\n",
33 s, PL_tainted, uid, euid));
34 }
35 # endif
a52cb5f7 »
1999-11-21 VMS patches from Peter Prymmer.
36 #endif
1e422769 »
1997-02-25 [inseparable changes from match from perl-5.003_90 to perl-5.003_91]
37
3280af22 »
1998-07-18 PL_ prefix to all perlvars, part1
38 if (PL_tainted) {
22c35a8c »
1998-10-30 phase 1 of somewhat major rearrangement of PERL_OBJECT stuff
39 if (!f)
40 f = PL_no_security;
3280af22 »
1998-07-18 PL_ prefix to all perlvars, part1
41 if (PL_euid != PL_uid)
bbce6d69 »
1996-11-26 [inseparable changes from patch from perl5.003_08 to perl5.003_09]
42 ug = " while running setuid";
3280af22 »
1998-07-18 PL_ prefix to all perlvars, part1
43 else if (PL_egid != PL_gid)
bbce6d69 »
1996-11-26 [inseparable changes from patch from perl5.003_08 to perl5.003_09]
44 ug = " while running setgid";
6537fe72 »
2001-12-13 -t taint warnings
45 else if (PL_taint_warn)
46 ug = " while running with -t switch";
47 else
bbce6d69 »
1996-11-26 [inseparable changes from patch from perl5.003_08 to perl5.003_09]
48 ug = " while running with -T switch";
6537fe72 »
2001-12-13 -t taint warnings
49 if (PL_unsafe || PL_taint_warn) {
50 if(ckWARN(WARN_TAINT))
51 Perl_warner(aTHX_ WARN_TAINT, f, s, ug);
52 }
53 else {
54 Perl_croak(aTHX_ f, s, ug);
55 }
79072805 »
1993-10-07 perl 5.0 alpha 2
56 }
57 }
58
59 void
864dbfa3 »
1999-06-07 initial stub implementation of implicit thread/this
60 Perl_taint_env(pTHX)
79072805 »
1993-10-07 perl 5.0 alpha 2
61 {
62 SV** svp;
7bac28a0 »
1997-05-08 [inseparable changes from match from perl-5.003_99 to perl-5.003_99a]
63 MAGIC* mg;
64 char** e;
65 static char* misc_env[] = {
66 "IFS", /* most shells' inter-field separators */
c90c0ff4 »
1997-05-16 [inseparable changes from match from perl-5.003_99a to perl5.004]
67 "CDPATH", /* ksh dain bramage #1 */
68 "ENV", /* ksh dain bramage #2 */
69 "BASH_ENV", /* bash dain bramage -- I guess it's contagious */
7bac28a0 »
1997-05-08 [inseparable changes from match from perl-5.003_99 to perl-5.003_99a]
70 NULL
71 };
1e422769 »
1997-02-25 [inseparable changes from match from perl-5.003_90 to perl-5.003_91]
72
142393a6 »
1998-12-30 "perl -T -P" dumps core on OpenBSD and Linux
73 if (!PL_envgv)
74 return;
75
1e422769 »
1997-02-25 [inseparable changes from match from perl-5.003_90 to perl-5.003_91]
76 #ifdef VMS
82f1aded »
1999-01-05 taint.c fix for VMS
77 {
1e422769 »
1997-02-25 [inseparable changes from match from perl-5.003_90 to perl-5.003_91]
78 int i = 0;
0dc443ab »
1997-03-01 Fix possible buffer overflow under VMS
79 char name[10 + TYPE_DIGITS(int)] = "DCL$PATH";
1e422769 »
1997-02-25 [inseparable changes from match from perl-5.003_90 to perl-5.003_91]
80
81 while (1) {
82 if (i)
83 (void)sprintf(name,"DCL$PATH;%d", i);
6b88bc9c »
1998-07-20 complete s/foo/PL_foo/ changes (all escaped cases identified with
84 svp = hv_fetch(GvHVn(PL_envgv), name, strlen(name), FALSE);
85 if (!svp || *svp == &PL_sv_undef)
1e422769 »
1997-02-25 [inseparable changes from match from perl-5.003_90 to perl-5.003_91]
86 break;
87 if (SvTAINTED(*svp)) {
88 TAINT;
89 taint_proper("Insecure %s%s", "$ENV{DCL$PATH}");
90 }
14befaf4 »
2001-05-19 [LARGE!] symbolic magic
91 if ((mg = mg_find(*svp, PERL_MAGIC_envelem)) && MgTAINTEDDIR(mg)) {
1e422769 »
1997-02-25 [inseparable changes from match from perl-5.003_90 to perl-5.003_91]
92 TAINT;
93 taint_proper("Insecure directory in %s%s", "$ENV{DCL$PATH}");
94 }
95 i++;
96 }
82f1aded »
1999-01-05 taint.c fix for VMS
97 }
1e422769 »
1997-02-25 [inseparable changes from match from perl-5.003_90 to perl-5.003_91]
98 #endif /* VMS */
79072805 »
1993-10-07 perl 5.0 alpha 2
99
3280af22 »
1998-07-18 PL_ prefix to all perlvars, part1
100 svp = hv_fetch(GvHVn(PL_envgv),"PATH",4,FALSE);
1e422769 »
1997-02-25 [inseparable changes from match from perl-5.003_90 to perl-5.003_91]
101 if (svp && *svp) {
102 if (SvTAINTED(*svp)) {
103 TAINT;
bbce6d69 »
1996-11-26 [inseparable changes from patch from perl5.003_08 to perl5.003_09]
104 taint_proper("Insecure %s%s", "$ENV{PATH}");
1e422769 »
1997-02-25 [inseparable changes from match from perl-5.003_90 to perl-5.003_91]
105 }
14befaf4 »
2001-05-19 [LARGE!] symbolic magic
106 if ((mg = mg_find(*svp, PERL_MAGIC_envelem)) && MgTAINTEDDIR(mg)) {
1e422769 »
1997-02-25 [inseparable changes from match from perl-5.003_90 to perl-5.003_91]
107 TAINT;
108 taint_proper("Insecure directory in %s%s", "$ENV{PATH}");
109 }
79072805 »
1993-10-07 perl 5.0 alpha 2
110 }
111
c90c0ff4 »
1997-05-16 [inseparable changes from match from perl-5.003_99a to perl5.004]
112 #ifndef VMS
113 /* tainted $TERM is okay if it contains no metachars */
3280af22 »
1998-07-18 PL_ prefix to all perlvars, part1
114 svp = hv_fetch(GvHVn(PL_envgv),"TERM",4,FALSE);
c90c0ff4 »
1997-05-16 [inseparable changes from match from perl-5.003_99a to perl5.004]
115 if (svp && *svp && SvTAINTED(*svp)) {
2d8e6c8d »
1998-11-29 another threads reliability fix: serialize writes to thr->threadsv
116 STRLEN n_a;
3280af22 »
1998-07-18 PL_ prefix to all perlvars, part1
117 bool was_tainted = PL_tainted;
2d8e6c8d »
1998-11-29 another threads reliability fix: serialize writes to thr->threadsv
118 char *t = SvPV(*svp, n_a);
119 char *e = t + n_a;
3280af22 »
1998-07-18 PL_ prefix to all perlvars, part1
120 PL_tainted = was_tainted;
c90c0ff4 »
1997-05-16 [inseparable changes from match from perl-5.003_99a to perl5.004]
121 if (t < e && isALNUM(*t))
122 t++;
123 while (t < e && (isALNUM(*t) || *t == '-' || *t == ':'))
124 t++;
125 if (t < e) {
126 TAINT;
127 taint_proper("Insecure $ENV{%s}%s", "TERM");
128 }
129 }
130 #endif /* !VMS */
131
7bac28a0 »
1997-05-08 [inseparable changes from match from perl-5.003_99 to perl-5.003_99a]
132 for (e = misc_env; *e; e++) {
3280af22 »
1998-07-18 PL_ prefix to all perlvars, part1
133 svp = hv_fetch(GvHVn(PL_envgv), *e, strlen(*e), FALSE);
134 if (svp && *svp != &PL_sv_undef && SvTAINTED(*svp)) {
7bac28a0 »
1997-05-08 [inseparable changes from match from perl-5.003_99 to perl-5.003_99a]
135 TAINT;
136 taint_proper("Insecure $ENV{%s}%s", *e);
137 }
bbce6d69 »
1996-11-26 [inseparable changes from patch from perl5.003_08 to perl5.003_09]
138 }
139 }
Something went wrong with that request. Please try again.