OpenCoverage

pathchk.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/coreutils/src/src/pathchk.c
Switch to Source codePreprocessed file
LineSourceCount
1-
2static -
3 _Bool -
4 validate_file_name (char *, -
5 _Bool-
6 , -
7 _Bool-
8 );-
9-
10-
11-
12enum-
13{-
14 PORTABILITY_OPTION = 0x7f + 1-
15};-
16-
17static struct option const longopts[] =-
18{-
19 {"portability", -
20 0-
21 , -
22 ((void *)0)-
23 , PORTABILITY_OPTION},-
24 {"help", -
25 0-
26 , -
27 ((void *)0)-
28 , GETOPT_HELP_CHAR},-
29 {"version", -
30 0-
31 , -
32 ((void *)0)-
33 , GETOPT_VERSION_CHAR},-
34 {-
35 ((void *)0)-
36 , 0, -
37 ((void *)0)-
38 , 0}-
39};-
40-
41void-
42usage (int status)-
43{-
44 if (status !=
status != 0Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • pathchk
FALSEevaluated 6 times by 1 test
Evaluated by:
  • pathchk
3-6
45 0
status != 0Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • pathchk
FALSEevaluated 6 times by 1 test
Evaluated by:
  • pathchk
3-6
46 )-
47 do { fprintf (-
48 stderr-
49 , -
50 dcgettext (((void *)0), -
51 "Try '%s --help' for more information.\n"-
52 , 5)-
53 , program_name); }
executed 3 times by 1 test: end of block
Executed by:
  • pathchk
while (0);
3
54 else-
55 {-
56 printf (-
57 dcgettext (((void *)0), -
58 "Usage: %s [OPTION]... NAME...\n"-
59 , 5)-
60 , program_name);-
61 fputs_unlocked (-
62 dcgettext (((void *)0), -
63 "Diagnose invalid or unportable file names.\n\n -p check for most POSIX systems\n -P check for empty names and leading \"-\"\n --portability check for all POSIX systems (equivalent to -p -P)\n"-
64 , 5)-
65 ,-
66 stdout-
67 )-
68-
69-
70-
71-
72-
73 ;-
74 fputs_unlocked (-
75 dcgettext (((void *)0), -
76 " --help display this help and exit\n"-
77 , 5)-
78 ,-
79 stdout-
80 );-
81 fputs_unlocked (-
82 dcgettext (((void *)0), -
83 " --version output version information and exit\n"-
84 , 5)-
85 ,-
86 stdout-
87 );-
88 emit_ancillary_info ("pathchk");-
89 }
executed 6 times by 1 test: end of block
Executed by:
  • pathchk
6
90 exit (status);
executed 9 times by 1 test: exit (status);
Executed by:
  • pathchk
9
91}-
92-
93int-
94main (int argc, char **argv)-
95{-
96 -
97 _Bool -
98 ok = -
99 1-
100 ;-
101 -
102 _Bool -
103 check_basic_portability = -
104 0-
105 ;-
106 -
107 _Bool -
108 check_extra_portability = -
109 0-
110 ;-
111 int optc;-
112-
113 ;-
114 set_program_name (argv[0]);-
115 setlocale (-
116 6-
117 , "");-
118 bindtextdomain ("coreutils", "/usr/local/share/locale");-
119 textdomain ("coreutils");-
120-
121 atexit (close_stdout);-
122-
123 while ((
(optc = getopt... *)0) )) != -1Description
TRUEevaluated 21 times by 1 test
Evaluated by:
  • pathchk
FALSEevaluated 6 times by 1 test
Evaluated by:
  • pathchk
optc = getopt_long (argc, argv, "+pP", longopts,
(optc = getopt... *)0) )) != -1Description
TRUEevaluated 21 times by 1 test
Evaluated by:
  • pathchk
FALSEevaluated 6 times by 1 test
Evaluated by:
  • pathchk
6-21
124 ((void *)0)
(optc = getopt... *)0) )) != -1Description
TRUEevaluated 21 times by 1 test
Evaluated by:
  • pathchk
FALSEevaluated 6 times by 1 test
Evaluated by:
  • pathchk
6-21
125 )) != -1
(optc = getopt... *)0) )) != -1Description
TRUEevaluated 21 times by 1 test
Evaluated by:
  • pathchk
FALSEevaluated 6 times by 1 test
Evaluated by:
  • pathchk
)
6-21
126 {-
127 switch (optc)-
128 {-
129 case
executed 1 time by 1 test: case PORTABILITY_OPTION:
Executed by:
  • pathchk
PORTABILITY_OPTION:
executed 1 time by 1 test: case PORTABILITY_OPTION:
Executed by:
  • pathchk
1
130 check_basic_portability = -
131 1-
132 ;-
133 check_extra_portability = -
134 1-
135 ;-
136 break;
executed 1 time by 1 test: break;
Executed by:
  • pathchk
1
137-
138 case
executed 3 times by 1 test: case 'p':
Executed by:
  • pathchk
'p':
executed 3 times by 1 test: case 'p':
Executed by:
  • pathchk
3
139 check_basic_portability = -
140 1-
141 ;-
142 break;
executed 3 times by 1 test: break;
Executed by:
  • pathchk
3
143-
144 case
executed 4 times by 1 test: case 'P':
Executed by:
  • pathchk
'P':
executed 4 times by 1 test: case 'P':
Executed by:
  • pathchk
4
145 check_extra_portability = -
146 1-
147 ;-
148 break;
executed 4 times by 1 test: break;
Executed by:
  • pathchk
4
149-
150 case
executed 6 times by 1 test: case GETOPT_HELP_CHAR:
Executed by:
  • pathchk
GETOPT_HELP_CHAR:
executed 6 times by 1 test: case GETOPT_HELP_CHAR:
Executed by:
  • pathchk
usage (
6
151 0-
152 ); break;
never executed: break;
;
0
153-
154 case
executed 4 times by 1 test: case GETOPT_VERSION_CHAR:
Executed by:
  • pathchk
GETOPT_VERSION_CHAR:
executed 4 times by 1 test: case GETOPT_VERSION_CHAR:
Executed by:
  • pathchk
version_etc (
4
155 stdout-
156 , "pathchk", "GNU coreutils", Version, ("Paul Eggert"), ("David MacKenzie"), ("Jim Meyering"), (char *) -
157 ((void *)0)-
158 ); exit (
executed 4 times by 1 test: exit ( 0 );
Executed by:
  • pathchk
4
159 0
executed 4 times by 1 test: exit ( 0 );
Executed by:
  • pathchk
4
160 );
executed 4 times by 1 test: exit ( 0 );
Executed by:
  • pathchk
break;
never executed: break;
;
0-4
161-
162 default
executed 3 times by 1 test: default:
Executed by:
  • pathchk
:
executed 3 times by 1 test: default:
Executed by:
  • pathchk
3
163 usage (-
164 1-
165 );-
166 }
never executed: end of block
0
167 }-
168-
169 if (optind == argc
optind == argcDescription
TRUEnever evaluated
FALSEevaluated 6 times by 1 test
Evaluated by:
  • pathchk
)
0-6
170 {-
171 error (0, 0, -
172 dcgettext (((void *)0), -
173 "missing operand"-
174 , 5)-
175 );-
176 usage (-
177 1-
178 );-
179 }
never executed: end of block
0
180-
181 for (; optind < argc
optind < argcDescription
TRUEevaluated 6 times by 1 test
Evaluated by:
  • pathchk
FALSEevaluated 6 times by 1 test
Evaluated by:
  • pathchk
; ++optind)
6
182 ok &= validate_file_name (argv[optind],
executed 6 times by 1 test: ok &= validate_file_name (argv[optind], check_basic_portability, check_extra_portability);
Executed by:
  • pathchk
6
183 check_basic_portability, check_extra_portability);
executed 6 times by 1 test: ok &= validate_file_name (argv[optind], check_basic_portability, check_extra_portability);
Executed by:
  • pathchk
6
184-
185 return
executed 6 times by 1 test: return ok ? 0 : 1 ;
Executed by:
  • pathchk
ok ?
executed 6 times by 1 test: return ok ? 0 : 1 ;
Executed by:
  • pathchk
6
186 0
executed 6 times by 1 test: return ok ? 0 : 1 ;
Executed by:
  • pathchk
6
187 :
executed 6 times by 1 test: return ok ? 0 : 1 ;
Executed by:
  • pathchk
6
188 1
executed 6 times by 1 test: return ok ? 0 : 1 ;
Executed by:
  • pathchk
6
189 ;
executed 6 times by 1 test: return ok ? 0 : 1 ;
Executed by:
  • pathchk
6
190}-
191-
192-
193-
194-
195static -
196 _Bool-
197-
198no_leading_hyphen (char const *file)-
199{-
200 char const *p;-
201-
202 for (p = file; (
(p = (__extens... p , '-' ))) )Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • pathchk
FALSEevaluated 1 time by 1 test
Evaluated by:
  • pathchk
p =
(p = (__extens... p , '-' ))) )Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • pathchk
FALSEevaluated 1 time by 1 test
Evaluated by:
  • pathchk
1-2
203 (__extension__ (__builtin_constant_p (
__builtin_constant_p ( '-' )Description
TRUEnever evaluated
FALSEnever evaluated
(p = (__extens... p , '-' ))) )Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • pathchk
FALSEevaluated 1 time by 1 test
Evaluated by:
  • pathchk
0-2
204 '-'
__builtin_constant_p ( '-' )Description
TRUEnever evaluated
FALSEnever evaluated
(p = (__extens... p , '-' ))) )Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • pathchk
FALSEevaluated 1 time by 1 test
Evaluated by:
  • pathchk
0-2
205 )
__builtin_constant_p ( '-' )Description
TRUEnever evaluated
FALSEnever evaluated
&& !__builtin_constant_p (
!__builtin_constant_p ( p )Description
TRUEnever evaluated
FALSEnever evaluated
(p = (__extens... p , '-' ))) )Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • pathchk
FALSEevaluated 1 time by 1 test
Evaluated by:
  • pathchk
0-2
206 p
!__builtin_constant_p ( p )Description
TRUEnever evaluated
FALSEnever evaluated
(p = (__extens... p , '-' ))) )Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • pathchk
FALSEevaluated 1 time by 1 test
Evaluated by:
  • pathchk
0-2
207 )
!__builtin_constant_p ( p )Description
TRUEnever evaluated
FALSEnever evaluated
&& (
( '-' ) == '\0'Description
TRUEnever evaluated
FALSEnever evaluated
(p = (__extens... p , '-' ))) )Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • pathchk
FALSEevaluated 1 time by 1 test
Evaluated by:
  • pathchk
0-2
208 '-'
( '-' ) == '\0'Description
TRUEnever evaluated
FALSEnever evaluated
(p = (__extens... p , '-' ))) )Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • pathchk
FALSEevaluated 1 time by 1 test
Evaluated by:
  • pathchk
0-2
209 ) == '\0'
( '-' ) == '\0'Description
TRUEnever evaluated
FALSEnever evaluated
? (char *) __rawmemchr (
(p = (__extens... p , '-' ))) )Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • pathchk
FALSEevaluated 1 time by 1 test
Evaluated by:
  • pathchk
0-2
210 p
(p = (__extens... p , '-' ))) )Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • pathchk
FALSEevaluated 1 time by 1 test
Evaluated by:
  • pathchk
1-2
211 ,
(p = (__extens... p , '-' ))) )Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • pathchk
FALSEevaluated 1 time by 1 test
Evaluated by:
  • pathchk
1-2
212 '-'
(p = (__extens... p , '-' ))) )Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • pathchk
FALSEevaluated 1 time by 1 test
Evaluated by:
  • pathchk
1-2
213 ) : __builtin_strchr (
(p = (__extens... p , '-' ))) )Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • pathchk
FALSEevaluated 1 time by 1 test
Evaluated by:
  • pathchk
1-2
214 p
(p = (__extens... p , '-' ))) )Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • pathchk
FALSEevaluated 1 time by 1 test
Evaluated by:
  • pathchk
1-2
215 ,
(p = (__extens... p , '-' ))) )Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • pathchk
FALSEevaluated 1 time by 1 test
Evaluated by:
  • pathchk
1-2
216 '-'
(p = (__extens... p , '-' ))) )Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • pathchk
FALSEevaluated 1 time by 1 test
Evaluated by:
  • pathchk
1-2
217 )))
(p = (__extens... p , '-' ))) )Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • pathchk
FALSEevaluated 1 time by 1 test
Evaluated by:
  • pathchk
1-2
218 )
(p = (__extens... p , '-' ))) )Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • pathchk
FALSEevaluated 1 time by 1 test
Evaluated by:
  • pathchk
; p++)
1-2
219 if (p == file
p == fileDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • pathchk
FALSEevaluated 1 time by 1 test
Evaluated by:
  • pathchk
|| p[-1] == '/'
p[-1] == '/'Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • pathchk
FALSEnever evaluated
)
0-1
220 {-
221 error (0, 0, -
222 dcgettext (((void *)0), -
223 "leading '-' in a component of file name %s"-
224 , 5)-
225 ,-
226 quotearg_style (shell_escape_always_quoting_style, file));-
227 return
executed 2 times by 1 test: return 0 ;
Executed by:
  • pathchk
executed 2 times by 1 test: return 0 ;
Executed by:
  • pathchk
2
228 0
executed 2 times by 1 test: return 0 ;
Executed by:
  • pathchk
2
229 ;
executed 2 times by 1 test: return 0 ;
Executed by:
  • pathchk
2
230 }-
231-
232 return
executed 1 time by 1 test: return 1 ;
Executed by:
  • pathchk
executed 1 time by 1 test: return 1 ;
Executed by:
  • pathchk
1
233 1
executed 1 time by 1 test: return 1 ;
Executed by:
  • pathchk
1
234 ;
executed 1 time by 1 test: return 1 ;
Executed by:
  • pathchk
1
235}-
236-
237-
238-
239-
240static -
241 _Bool-
242-
243portable_chars_only (char const *file, size_t filelen)-
244{-
245 size_t validlen = -
246 __builtin_strspn (-
247 file-
248 , -
249 ("/" "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "abcdefghijklmnopqrstuvwxyz" "0123456789._-")-
250 )-
251-
252-
253-
254 -
255 ;-
256 char const *invalid = file + validlen;-
257-
258 if (*
*invalidDescription
TRUEnever evaluated
FALSEnever evaluated
invalid
*invalidDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
259 {-
260 mbstate_t mbstate = { 0, };-
261 size_t charlen = -
262 rpl_mbrlen -
263 (invalid, filelen - validlen, &mbstate);-
264 error (0, 0,-
265 -
266 dcgettext (((void *)0), -
267 "nonportable character %s in file name %s"-
268 , 5)-
269 ,-
270 quotearg_n_style_mem (1, locale_quoting_style, invalid,-
271 (charlen <= -
272 16 -
273 ? charlen : 1)),-
274 quotearg_n_style (0, shell_escape_always_quoting_style, file));-
275 return
never executed: return 0 ;
never executed: return 0 ;
0
276 0
never executed: return 0 ;
0
277 ;
never executed: return 0 ;
0
278 }-
279-
280 return
never executed: return 1 ;
never executed: return 1 ;
0
281 1
never executed: return 1 ;
0
282 ;
never executed: return 1 ;
0
283}-
284-
285-
286-
287static char * -
288 __attribute__ ((__pure__))-
289-
290component_start (char *f)-
291{-
292 while (*
*f == '/'Description
TRUEnever evaluated
FALSEnever evaluated
f == '/'
*f == '/'Description
TRUEnever evaluated
FALSEnever evaluated
)
0
293 f++;
never executed: f++;
0
294 return
never executed: return f;
f;
never executed: return f;
0
295}-
296-
297-
298-
299static size_t -
300 __attribute__ ((__pure__))-
301-
302component_len (char const *f)-
303{-
304 size_t len;-
305 for (len = 1; f[len] != '/'
f[len] != '/'Description
TRUEnever evaluated
FALSEnever evaluated
&& f[len]
f[len]Description
TRUEnever evaluated
FALSEnever evaluated
; len++)
0
306 continue;
never executed: continue;
0
307 return
never executed: return len;
len;
never executed: return len;
0
308}-
309static -
310 _Bool-
311-
312validate_file_name (char *file, -
313 _Bool -
314 check_basic_portability,-
315 -
316 _Bool -
317 check_extra_portability)-
318{-
319 size_t filelen = strlen (file);-
320-
321-
322 char *start;-
323-
324-
325 -
326 _Bool -
327 check_component_lengths;-
328-
329-
330 -
331 _Bool -
332 file_exists = -
333 0-
334 ;-
335-
336 if (check_extra_portability
check_extra_portabilityDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • pathchk
FALSEevaluated 3 times by 1 test
Evaluated by:
  • pathchk
&& ! no_leading_hyphen (file)
! no_leading_hyphen (file)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • pathchk
FALSEevaluated 1 time by 1 test
Evaluated by:
  • pathchk
)
1-3
337 return
executed 2 times by 1 test: return 0 ;
Executed by:
  • pathchk
executed 2 times by 1 test: return 0 ;
Executed by:
  • pathchk
2
338 0
executed 2 times by 1 test: return 0 ;
Executed by:
  • pathchk
2
339 ;
executed 2 times by 1 test: return 0 ;
Executed by:
  • pathchk
2
340-
341 if ((check_basic_portability
check_basic_portabilityDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • pathchk
FALSEevaluated 3 times by 1 test
Evaluated by:
  • pathchk
|| check_extra_portability
check_extra_portabilityDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • pathchk
FALSEevaluated 2 times by 1 test
Evaluated by:
  • pathchk
)
1-3
342 && filelen == 0
filelen == 0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • pathchk
FALSEnever evaluated
)
0-2
343 {-
344-
345-
346-
347-
348 error (0, 0, -
349 dcgettext (((void *)0), -
350 "empty file name"-
351 , 5)-
352 );-
353 return
executed 2 times by 1 test: return 0 ;
Executed by:
  • pathchk
executed 2 times by 1 test: return 0 ;
Executed by:
  • pathchk
2
354 0
executed 2 times by 1 test: return 0 ;
Executed by:
  • pathchk
2
355 ;
executed 2 times by 1 test: return 0 ;
Executed by:
  • pathchk
2
356 }-
357-
358 if (check_basic_portability
check_basic_portabilityDescription
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • pathchk
)
0-2
359 {-
360 if (! portable_chars_only (file, filelen)
! portable_cha...file, filelen)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
361 return
never executed: return 0 ;
never executed: return 0 ;
0
362 0
never executed: return 0 ;
0
363 ;
never executed: return 0 ;
0
364 }
never executed: end of block
0
365 else-
366 {-
367-
368-
369-
370-
371-
372 struct stat st;-
373 if (lstat (file, &st) == 0
lstat (file, &st) == 0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • pathchk
FALSEevaluated 1 time by 1 test
Evaluated by:
  • pathchk
)
1
374 file_exists =
executed 1 time by 1 test: file_exists = 1 ;
Executed by:
  • pathchk
1
375 1
executed 1 time by 1 test: file_exists = 1 ;
Executed by:
  • pathchk
1
376 ;
executed 1 time by 1 test: file_exists = 1 ;
Executed by:
  • pathchk
1
377 else if (-
378 (*
(*__errno_location ()) != 2Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • pathchk
FALSEnever evaluated
__errno_location ())
(*__errno_location ()) != 2Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • pathchk
FALSEnever evaluated
0-1
379 !=
(*__errno_location ()) != 2Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • pathchk
FALSEnever evaluated
0-1
380 2
(*__errno_location ()) != 2Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • pathchk
FALSEnever evaluated
0-1
381 || filelen == 0
filelen == 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
382 {-
383 error (0, -
384 (*__errno_location ())-
385 , "%s", quotearg_n_style_colon (0, shell_escape_quoting_style, file));-
386 return
executed 1 time by 1 test: return 0 ;
Executed by:
  • pathchk
executed 1 time by 1 test: return 0 ;
Executed by:
  • pathchk
1
387 0
executed 1 time by 1 test: return 0 ;
Executed by:
  • pathchk
1
388 ;
executed 1 time by 1 test: return 0 ;
Executed by:
  • pathchk
1
389 }-
390 }
executed 1 time by 1 test: end of block
Executed by:
  • pathchk
1
391-
392 if (check_basic_portability
check_basic_portabilityDescription
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • pathchk
0-1
393 || (! file_exists
! file_existsDescription
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • pathchk
&&
0-1
394 256
256 <= filelenDescription
TRUEnever evaluated
FALSEnever evaluated
0
395 <= filelen
256 <= filelenDescription
TRUEnever evaluated
FALSEnever evaluated
))
0
396 {-
397 size_t maxsize;-
398-
399 if (check_basic_portability
check_basic_portabilityDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
400 maxsize =
never executed: maxsize = 256 ;
0
401 256
never executed: maxsize = 256 ;
0
402 ;
never executed: maxsize = 256 ;
0
403 else-
404 {-
405 long int size;-
406 char const *dir = (*
*file == '/'Description
TRUEnever evaluated
FALSEnever evaluated
file == '/'
*file == '/'Description
TRUEnever evaluated
FALSEnever evaluated
? "/" : ".");
0
407 -
408 (*__errno_location ()) -
409 = 0;-
410 size = pathconf (dir, -
411 _PC_PATH_MAX-
412 );-
413 if (size < 0
size < 0Description
TRUEnever evaluated
FALSEnever evaluated
&&
0
414 (*
(*__errno_location ()) != 0Description
TRUEnever evaluated
FALSEnever evaluated
__errno_location ())
(*__errno_location ()) != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
415 != 0
(*__errno_location ()) != 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
416 {-
417 error (0, -
418 (*__errno_location ())-
419 ,-
420 -
421 dcgettext (((void *)0), -
422 "%s: unable to determine maximum file name length"-
423 , 5)-
424 ,-
425 dir);-
426 return
never executed: return 0 ;
never executed: return 0 ;
0
427 0
never executed: return 0 ;
0
428 ;
never executed: return 0 ;
0
429 }-
430 maxsize = -
431 (((
(( size )<(0x7...fffffffffffL))Description
TRUEnever evaluated
FALSEnever evaluated
0
432 size
(( size )<(0x7...fffffffffffL))Description
TRUEnever evaluated
FALSEnever evaluated
0
433 )<(0x7fffffffffffffffL))
(( size )<(0x7...fffffffffffL))Description
TRUEnever evaluated
FALSEnever evaluated
?(
0
434 size-
435 ):(0x7fffffffffffffffL))-
436 ;-
437 }
never executed: end of block
0
438-
439 if (maxsize <= filelen
maxsize <= filelenDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
440 {-
441 unsigned long int len = filelen;-
442 unsigned long int maxlen = maxsize - 1;-
443 error (0, 0, -
444 dcgettext (((void *)0), -
445 "limit %lu exceeded by length %lu of file name %s"-
446 , 5)-
447 ,-
448 maxlen, len, quotearg_style (shell_escape_always_quoting_style, file));-
449 return
never executed: return 0 ;
never executed: return 0 ;
0
450 0
never executed: return 0 ;
0
451 ;
never executed: return 0 ;
0
452 }-
453 }
never executed: end of block
0
454-
455-
456-
457-
458-
459-
460 check_component_lengths = check_basic_portability;-
461 if (! check_component_lengths
! check_component_lengthsDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • pathchk
FALSEnever evaluated
&& ! file_exists
! file_existsDescription
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • pathchk
)
0-1
462 {-
463 for (start = file; *(
*(start = comp...start (start))Description
TRUEnever evaluated
FALSEnever evaluated
start = component_start (start))
*(start = comp...start (start))Description
TRUEnever evaluated
FALSEnever evaluated
; )
0
464 {-
465 size_t length = component_len (start);-
466-
467 if (-
468 14
14 < lengthDescription
TRUEnever evaluated
FALSEnever evaluated
0
469 < length
14 < lengthDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
470 {-
471 check_component_lengths = -
472 1-
473 ;-
474 break;
never executed: break;
0
475 }-
476-
477 start += length;-
478 }
never executed: end of block
0
479 }
never executed: end of block
0
480-
481 if (check_component_lengths
check_component_lengthsDescription
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • pathchk
)
0-1
482 {-
483-
484-
485-
486-
487 size_t name_max = -
488 14-
489 ;-
490-
491-
492 size_t known_name_max = (check_basic_portability
check_basic_portabilityDescription
TRUEnever evaluated
FALSEnever evaluated
?
0
493 14 -
494 : 0);-
495-
496 for (start = file; *(
*(start = comp...start (start))Description
TRUEnever evaluated
FALSEnever evaluated
start = component_start (start))
*(start = comp...start (start))Description
TRUEnever evaluated
FALSEnever evaluated
; )
0
497 {-
498 size_t length;-
499-
500 if (known_name_max
known_name_maxDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
501 name_max = known_name_max;
never executed: name_max = known_name_max;
0
502 else-
503 {-
504 long int len;-
505 char const *dir = (start == file
start == fileDescription
TRUEnever evaluated
FALSEnever evaluated
? "." : file);
0
506 char c = *start;-
507 -
508 (*__errno_location ()) -
509 = 0;-
510 *start = '\0';-
511 len = pathconf (dir, -
512 _PC_NAME_MAX-
513 );-
514 *start = c;-
515 if (0 <= len
0 <= lenDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
516 name_max =
never executed: name_max = ((( len )<(0x7fffffffffffffffL))?( len ):(0x7fffffffffffffffL)) ;
0
517 (((
(( len )<(0x7f...fffffffffffL))Description
TRUEnever evaluated
FALSEnever evaluated
never executed: name_max = ((( len )<(0x7fffffffffffffffL))?( len ):(0x7fffffffffffffffL)) ;
0
518 len
(( len )<(0x7f...fffffffffffL))Description
TRUEnever evaluated
FALSEnever evaluated
never executed: name_max = ((( len )<(0x7fffffffffffffffL))?( len ):(0x7fffffffffffffffL)) ;
0
519 )<(0x7fffffffffffffffL))
(( len )<(0x7f...fffffffffffL))Description
TRUEnever evaluated
FALSEnever evaluated
?(
never executed: name_max = ((( len )<(0x7fffffffffffffffL))?( len ):(0x7fffffffffffffffL)) ;
0
520 len
never executed: name_max = ((( len )<(0x7fffffffffffffffL))?( len ):(0x7fffffffffffffffL)) ;
0
521 ):(0x7fffffffffffffffL))
never executed: name_max = ((( len )<(0x7fffffffffffffffL))?( len ):(0x7fffffffffffffffL)) ;
0
522 ;
never executed: name_max = ((( len )<(0x7fffffffffffffffL))?( len ):(0x7fffffffffffffffL)) ;
0
523 else-
524 switch (-
525 (*__errno_location ())-
526 )-
527 {-
528 case
never executed: case 0:
0:
never executed: case 0:
0
529-
530 name_max = -
531 (18446744073709551615UL)-
532 ;-
533 break;
never executed: break;
0
534-
535 case
never executed: case 2 :
never executed: case 2 :
0
536 2
never executed: case 2 :
0
537 :
never executed: case 2 :
0
538-
539 known_name_max = name_max;-
540 break;
never executed: break;
0
541-
542 default
never executed: default:
:
never executed: default:
0
543 *start = '\0';-
544 error (0, -
545 (*__errno_location ())-
546 , "%s", quotearg_n_style_colon (0, shell_escape_quoting_style, dir));-
547 *start = c;-
548 return
never executed: return 0 ;
never executed: return 0 ;
0
549 0
never executed: return 0 ;
0
550 ;
never executed: return 0 ;
0
551 }-
552 }-
553-
554 length = component_len (start);-
555-
556 if (name_max < length
name_max < lengthDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
557 {-
558 unsigned long int len = length;-
559 unsigned long int maxlen = name_max;-
560 char c = start[len];-
561 start[len] = '\0';-
562 error (0, 0,-
563 -
564 dcgettext (((void *)0), -
565 "limit %lu exceeded by length %lu " "of file name component %s"-
566 , 5)-
567 -
568 ,-
569 maxlen, len, quote (start));-
570 start[len] = c;-
571 return
never executed: return 0 ;
never executed: return 0 ;
0
572 0
never executed: return 0 ;
0
573 ;
never executed: return 0 ;
0
574 }-
575-
576 start += length;-
577 }
never executed: end of block
0
578 }
never executed: end of block
0
579-
580 return
executed 1 time by 1 test: return 1 ;
Executed by:
  • pathchk
executed 1 time by 1 test: return 1 ;
Executed by:
  • pathchk
1
581 1
executed 1 time by 1 test: return 1 ;
Executed by:
  • pathchk
1
582 ;
executed 1 time by 1 test: return 1 ;
Executed by:
  • pathchk
1
583}-
Switch to Source codePreprocessed file

Generated by Squish Coco 4.1.2