line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#include "EXTERN.h" |
2
|
|
|
|
|
|
|
#include "perl.h" |
3
|
|
|
|
|
|
|
#include "XSUB.h" |
4
|
|
|
|
|
|
|
#include "hook_op_check.h" |
5
|
|
|
|
|
|
|
#include "ppport.h" |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
#define PERL_VERSION_DECIMAL(r,v,s) (r*1000000 + v*1000 + s) |
8
|
|
|
|
|
|
|
#define PERL_DECIMAL_VERSION \ |
9
|
|
|
|
|
|
|
PERL_VERSION_DECIMAL(PERL_REVISION,PERL_VERSION,PERL_SUBVERSION) |
10
|
|
|
|
|
|
|
#define PERL_VERSION_GE(r,v,s) \ |
11
|
|
|
|
|
|
|
(PERL_DECIMAL_VERSION >= PERL_VERSION_DECIMAL(r,v,s)) |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
#if PERL_VERSION_GE(5,9,2) |
14
|
|
|
|
|
|
|
#define CONST const |
15
|
|
|
|
|
|
|
#else |
16
|
|
|
|
|
|
|
#define CONST /**/ |
17
|
|
|
|
|
|
|
#endif |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
#define bareword_croak_unless_builtin(op, gv) \ |
20
|
|
|
|
|
|
|
THX_bareword_croak_unless_builtin(aTHX_ op, gv) |
21
|
259
|
|
|
|
|
|
STATIC void THX_bareword_croak_unless_builtin (pTHX_ CONST OP *op, const GV *gv) { |
22
|
259
|
50
|
|
|
|
|
if (gv |
23
|
259
|
100
|
|
|
|
|
&& gv != PL_stdingv |
24
|
216
|
100
|
|
|
|
|
&& gv != PL_stderrgv |
25
|
173
|
50
|
|
|
|
|
&& gv != PL_defgv |
26
|
173
|
100
|
|
|
|
|
&& gv != PL_argvgv |
27
|
130
|
50
|
|
|
|
|
&& gv != PL_argvoutgv |
28
|
130
|
100
|
|
|
|
|
&& gv != gv_fetchpv("STDOUT", TRUE, SVt_PVIO) |
29
|
87
|
100
|
|
|
|
|
&& gv != gv_fetchpv("DATA", TRUE, SVt_PVIO) |
30
|
|
|
|
|
|
|
) |
31
|
44
|
50
|
|
|
|
|
croak("Use of bareword filehandle in %s", OP_DESC(op)); |
32
|
215
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
#define bareword_croak_unless_builtin_op(op, argop) \ |
35
|
|
|
|
|
|
|
THX_bareword_croak_unless_builtin_op(aTHX_ op, argop) |
36
|
240
|
|
|
|
|
|
STATIC void THX_bareword_croak_unless_builtin_op (pTHX_ CONST OP *op, const OP *argop) { |
37
|
240
|
50
|
|
|
|
|
if (argop && argop->op_type == OP_GV) |
|
|
100
|
|
|
|
|
|
38
|
225
|
|
|
|
|
|
bareword_croak_unless_builtin(op, cGVOPx_gv(argop)); |
39
|
15
|
50
|
|
|
|
|
else if (argop && argop->op_type == OP_CONST && |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
40
|
12
|
|
|
|
|
|
(argop->op_private & OPpCONST_BARE)) { |
41
|
12
|
|
|
|
|
|
const GV *gv = gv_fetchsv(cSVOPx(argop)->op_sv, 0, SVt_PVIO); |
42
|
12
|
|
|
|
|
|
bareword_croak_unless_builtin(op, gv); |
43
|
|
|
|
|
|
|
} |
44
|
198
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
92
|
|
|
|
|
|
STATIC OP *bareword_filehandles_unary_check_op (pTHX_ OP *op, void *user_data) { |
47
|
92
|
|
|
|
|
|
SV **hint = hv_fetchs(GvHV(PL_hintgv), "bareword::filehandles/disabled", 0); |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
PERL_UNUSED_ARG(user_data); |
50
|
|
|
|
|
|
|
|
51
|
92
|
100
|
|
|
|
|
if (!hint || !SvOK(*hint)) |
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
52
|
1
|
|
|
|
|
|
return op; |
53
|
|
|
|
|
|
|
|
54
|
91
|
100
|
|
|
|
|
if (op->op_flags & OPf_KIDS) |
55
|
78
|
|
|
|
|
|
bareword_croak_unless_builtin_op(op, cUNOPx(op)->op_first); |
56
|
|
|
|
|
|
|
|
57
|
78
|
|
|
|
|
|
return op; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
26
|
|
|
|
|
|
STATIC OP *bareword_filehandles_stat_check_op (pTHX_ OP *op, void *user_data) { |
61
|
26
|
|
|
|
|
|
SV **hint = hv_fetchs(GvHV(PL_hintgv), "bareword::filehandles/disabled", 0); |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
PERL_UNUSED_ARG(user_data); |
64
|
|
|
|
|
|
|
|
65
|
26
|
50
|
|
|
|
|
if (!hint || !SvOK(*hint)) |
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
66
|
0
|
|
|
|
|
|
return op; |
67
|
|
|
|
|
|
|
|
68
|
26
|
100
|
|
|
|
|
if (op->op_flags & OPf_REF) |
69
|
22
|
|
|
|
|
|
bareword_croak_unless_builtin(op, cGVOPx_gv(op)); |
70
|
|
|
|
|
|
|
|
71
|
24
|
|
|
|
|
|
return op; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
185
|
|
|
|
|
|
STATIC OP *bareword_filehandles_list_check_op (pTHX_ OP *op, void *user_data) { |
75
|
185
|
|
|
|
|
|
SV **hint = hv_fetchs(GvHV(PL_hintgv), "bareword::filehandles/disabled", 0); |
76
|
|
|
|
|
|
|
OP *child; |
77
|
185
|
100
|
|
|
|
|
int num_args = user_data ? *(int*)user_data : 1; |
78
|
|
|
|
|
|
|
|
79
|
185
|
50
|
|
|
|
|
if (!hint || !SvOK(*hint)) |
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
80
|
0
|
|
|
|
|
|
return op; |
81
|
|
|
|
|
|
|
|
82
|
185
|
|
|
|
|
|
child = cLISTOPx(op)->op_first; |
83
|
185
|
50
|
|
|
|
|
if (child && (child->op_type == OP_PUSHMARK || child->op_type == OP_NULL)) { |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
84
|
318
|
100
|
|
|
|
|
while(num_args-- && (child = OpSIBLING(child))) |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
85
|
162
|
|
|
|
|
|
bareword_croak_unless_builtin_op(op, child); |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
156
|
|
|
|
|
|
return op; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
STATIC const int bareword_filehandles_two = 2; |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
MODULE = bareword::filehandles PACKAGE = bareword::filehandles |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
PROTOTYPES: ENABLE |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
#define bareword_check(type, op) \ |
98
|
|
|
|
|
|
|
hook_op_check(op, bareword_filehandles_##type##_check_op, NULL); |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
#define bareword_check_list2(op) \ |
101
|
|
|
|
|
|
|
hook_op_check(op, bareword_filehandles_list_check_op, \ |
102
|
|
|
|
|
|
|
(void*)&bareword_filehandles_two); |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
BOOT: |
105
|
1
|
|
|
|
|
|
bareword_check(unary, OP_CLOSE); |
106
|
1
|
|
|
|
|
|
bareword_check(unary, OP_CLOSEDIR); |
107
|
1
|
|
|
|
|
|
bareword_check(unary, OP_ENTERWRITE); |
108
|
1
|
|
|
|
|
|
bareword_check(unary, OP_EOF); |
109
|
1
|
|
|
|
|
|
bareword_check(unary, OP_FILENO); |
110
|
1
|
|
|
|
|
|
bareword_check(unary, OP_GETC); |
111
|
1
|
|
|
|
|
|
bareword_check(unary, OP_GETPEERNAME); |
112
|
1
|
|
|
|
|
|
bareword_check(unary, OP_GETSOCKNAME); |
113
|
1
|
|
|
|
|
|
bareword_check(unary, OP_READDIR); |
114
|
1
|
|
|
|
|
|
bareword_check(unary, OP_READLINE); |
115
|
1
|
|
|
|
|
|
bareword_check(unary, OP_REWINDDIR); |
116
|
1
|
|
|
|
|
|
bareword_check(unary, OP_TELL); |
117
|
1
|
|
|
|
|
|
bareword_check(unary, OP_TELLDIR); |
118
|
1
|
|
|
|
|
|
bareword_check(unary, OP_CHDIR); |
119
|
|
|
|
|
|
|
|
120
|
1
|
|
|
|
|
|
bareword_check(list, OP_BIND); |
121
|
1
|
|
|
|
|
|
bareword_check(list, OP_BINMODE); |
122
|
1
|
|
|
|
|
|
bareword_check(list, OP_CONNECT); |
123
|
1
|
|
|
|
|
|
bareword_check(list, OP_FCNTL); |
124
|
1
|
|
|
|
|
|
bareword_check(list, OP_FLOCK); |
125
|
1
|
|
|
|
|
|
bareword_check(list, OP_GSOCKOPT); |
126
|
1
|
|
|
|
|
|
bareword_check(list, OP_IOCTL); |
127
|
1
|
|
|
|
|
|
bareword_check(list, OP_LISTEN); |
128
|
1
|
|
|
|
|
|
bareword_check(list, OP_OPEN); |
129
|
1
|
|
|
|
|
|
bareword_check(list, OP_OPEN_DIR); |
130
|
1
|
|
|
|
|
|
bareword_check(list, OP_READ); |
131
|
1
|
|
|
|
|
|
bareword_check(list, OP_RECV); |
132
|
1
|
|
|
|
|
|
bareword_check(list, OP_SEEK); |
133
|
1
|
|
|
|
|
|
bareword_check(list, OP_SEEKDIR); |
134
|
1
|
|
|
|
|
|
bareword_check(list, OP_SELECT); |
135
|
1
|
|
|
|
|
|
bareword_check(list, OP_SEND); |
136
|
1
|
|
|
|
|
|
bareword_check(list, OP_SHUTDOWN); |
137
|
1
|
|
|
|
|
|
bareword_check(list, OP_SOCKET); |
138
|
1
|
|
|
|
|
|
bareword_check(list, OP_SSOCKOPT); |
139
|
1
|
|
|
|
|
|
bareword_check(list, OP_SYSREAD); |
140
|
1
|
|
|
|
|
|
bareword_check(list, OP_SYSSEEK); |
141
|
1
|
|
|
|
|
|
bareword_check(list, OP_SYSWRITE); |
142
|
1
|
|
|
|
|
|
bareword_check(list, OP_TRUNCATE); |
143
|
1
|
|
|
|
|
|
bareword_check_list2(OP_ACCEPT); |
144
|
1
|
|
|
|
|
|
bareword_check_list2(OP_PIPE_OP); |
145
|
1
|
|
|
|
|
|
bareword_check_list2(OP_SOCKPAIR); |
146
|
|
|
|
|
|
|
|
147
|
1
|
|
|
|
|
|
bareword_check(stat, OP_STAT); |
148
|
1
|
|
|
|
|
|
bareword_check(stat, OP_LSTAT); |
149
|
|
|
|
|
|
|
#if PERL_VERSION_GE(5,31,1) |
150
|
|
|
|
|
|
|
bareword_check(stat, OP_FTRREAD); |
151
|
|
|
|
|
|
|
bareword_check(stat, OP_FTRWRITE); |
152
|
|
|
|
|
|
|
bareword_check(stat, OP_FTREXEC); |
153
|
|
|
|
|
|
|
bareword_check(stat, OP_FTEREAD); |
154
|
|
|
|
|
|
|
bareword_check(stat, OP_FTEWRITE); |
155
|
|
|
|
|
|
|
bareword_check(stat, OP_FTEEXEC); |
156
|
|
|
|
|
|
|
bareword_check(stat, OP_FTIS); |
157
|
|
|
|
|
|
|
bareword_check(stat, OP_FTSIZE); |
158
|
|
|
|
|
|
|
bareword_check(stat, OP_FTMTIME); |
159
|
|
|
|
|
|
|
bareword_check(stat, OP_FTATIME); |
160
|
|
|
|
|
|
|
bareword_check(stat, OP_FTCTIME); |
161
|
|
|
|
|
|
|
bareword_check(stat, OP_FTROWNED); |
162
|
|
|
|
|
|
|
bareword_check(stat, OP_FTEOWNED); |
163
|
|
|
|
|
|
|
bareword_check(stat, OP_FTZERO); |
164
|
|
|
|
|
|
|
bareword_check(stat, OP_FTSOCK); |
165
|
|
|
|
|
|
|
bareword_check(stat, OP_FTCHR); |
166
|
|
|
|
|
|
|
bareword_check(stat, OP_FTBLK); |
167
|
|
|
|
|
|
|
bareword_check(stat, OP_FTFILE); |
168
|
|
|
|
|
|
|
bareword_check(stat, OP_FTDIR); |
169
|
|
|
|
|
|
|
bareword_check(stat, OP_FTPIPE); |
170
|
|
|
|
|
|
|
bareword_check(stat, OP_FTSUID); |
171
|
|
|
|
|
|
|
bareword_check(stat, OP_FTSGID); |
172
|
|
|
|
|
|
|
bareword_check(stat, OP_FTSVTX); |
173
|
|
|
|
|
|
|
bareword_check(stat, OP_FTLINK); |
174
|
|
|
|
|
|
|
bareword_check(stat, OP_FTTTY); |
175
|
|
|
|
|
|
|
bareword_check(stat, OP_FTTEXT); |
176
|
|
|
|
|
|
|
bareword_check(stat, OP_FTBINARY); |
177
|
|
|
|
|
|
|
#endif |