| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/coreutils/src/src/pathchk.c |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||
| 2 | static | - | ||||||||||||||||||
| 3 | _Bool | - | ||||||||||||||||||
| 4 | validate_file_name (char *, | - | ||||||||||||||||||
| 5 | _Bool | - | ||||||||||||||||||
| 6 | , | - | ||||||||||||||||||
| 7 | _Bool | - | ||||||||||||||||||
| 8 | ); | - | ||||||||||||||||||
| 9 | - | |||||||||||||||||||
| 10 | - | |||||||||||||||||||
| 11 | - | |||||||||||||||||||
| 12 | enum | - | ||||||||||||||||||
| 13 | { | - | ||||||||||||||||||
| 14 | PORTABILITY_OPTION = 0x7f + 1 | - | ||||||||||||||||||
| 15 | }; | - | ||||||||||||||||||
| 16 | - | |||||||||||||||||||
| 17 | static 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 | - | |||||||||||||||||||
| 41 | void | - | ||||||||||||||||||
| 42 | usage (int status) | - | ||||||||||||||||||
| 43 | { | - | ||||||||||||||||||
| 44 | if (status !=
| 3-6 | ||||||||||||||||||
| 45 | 0
| 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: while (0);end of blockExecuted by:
| 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 blockExecuted by:
| 6 | ||||||||||||||||||
| 90 | exit (status); executed 9 times by 1 test: exit (status);Executed by:
| 9 | ||||||||||||||||||
| 91 | } | - | ||||||||||||||||||
| 92 | - | |||||||||||||||||||
| 93 | int | - | ||||||||||||||||||
| 94 | main (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 ((
| 6-21 | ||||||||||||||||||
| 124 | ((void *)0)
| 6-21 | ||||||||||||||||||
| 125 | )) != -1
| 6-21 | ||||||||||||||||||
| 126 | { | - | ||||||||||||||||||
| 127 | switch (optc) | - | ||||||||||||||||||
| 128 | { | - | ||||||||||||||||||
| 129 | case executed 1 time by 1 test: PORTABILITY_OPTION:case PORTABILITY_OPTION:Executed by:
executed 1 time by 1 test: case PORTABILITY_OPTION:Executed by:
| 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:
| 1 | ||||||||||||||||||
| 137 | - | |||||||||||||||||||
| 138 | case executed 3 times by 1 test: 'p':case 'p':Executed by:
executed 3 times by 1 test: case 'p':Executed by:
| 3 | ||||||||||||||||||
| 139 | check_basic_portability = | - | ||||||||||||||||||
| 140 | 1 | - | ||||||||||||||||||
| 141 | ; | - | ||||||||||||||||||
| 142 | break; executed 3 times by 1 test: break;Executed by:
| 3 | ||||||||||||||||||
| 143 | - | |||||||||||||||||||
| 144 | case executed 4 times by 1 test: 'P':case 'P':Executed by:
executed 4 times by 1 test: case 'P':Executed by:
| 4 | ||||||||||||||||||
| 145 | check_extra_portability = | - | ||||||||||||||||||
| 146 | 1 | - | ||||||||||||||||||
| 147 | ; | - | ||||||||||||||||||
| 148 | break; executed 4 times by 1 test: break;Executed by:
| 4 | ||||||||||||||||||
| 149 | - | |||||||||||||||||||
| 150 | case executed 6 times by 1 test: GETOPT_HELP_CHAR:case GETOPT_HELP_CHAR:Executed by:
executed 6 times by 1 test: usage (case GETOPT_HELP_CHAR:Executed by:
| 6 | ||||||||||||||||||
| 151 | 0 | - | ||||||||||||||||||
| 152 | ); break; never executed: ;break; | 0 | ||||||||||||||||||
| 153 | - | |||||||||||||||||||
| 154 | case executed 4 times by 1 test: GETOPT_VERSION_CHAR:case GETOPT_VERSION_CHAR:Executed by:
executed 4 times by 1 test: version_etc (case GETOPT_VERSION_CHAR:Executed by:
| 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:
| 4 | ||||||||||||||||||
| 159 | 0 executed 4 times by 1 test: exit ( 0 );Executed by:
| 4 | ||||||||||||||||||
| 160 | ); executed 4 times by 1 test: break;exit ( 0 );Executed by:
never executed: ;break; | 0-4 | ||||||||||||||||||
| 161 | - | |||||||||||||||||||
| 162 | default executed 3 times by 1 test: :default:Executed by:
executed 3 times by 1 test: default:Executed by:
| 3 | ||||||||||||||||||
| 163 | usage ( | - | ||||||||||||||||||
| 164 | 1 | - | ||||||||||||||||||
| 165 | ); | - | ||||||||||||||||||
| 166 | } never executed: end of block | 0 | ||||||||||||||||||
| 167 | } | - | ||||||||||||||||||
| 168 | - | |||||||||||||||||||
| 169 | if (optind == argc
| 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
| 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:
| 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:
| 6 | ||||||||||||||||||
| 184 | - | |||||||||||||||||||
| 185 | return executed 6 times by 1 test: ok ? return ok ? 0 : 1 ;Executed by:
executed 6 times by 1 test: return ok ? 0 : 1 ;Executed by:
| 6 | ||||||||||||||||||
| 186 | 0 executed 6 times by 1 test: return ok ? 0 : 1 ;Executed by:
| 6 | ||||||||||||||||||
| 187 | : executed 6 times by 1 test: return ok ? 0 : 1 ;Executed by:
| 6 | ||||||||||||||||||
| 188 | 1 executed 6 times by 1 test: return ok ? 0 : 1 ;Executed by:
| 6 | ||||||||||||||||||
| 189 | ; executed 6 times by 1 test: return ok ? 0 : 1 ;Executed by:
| 6 | ||||||||||||||||||
| 190 | } | - | ||||||||||||||||||
| 191 | - | |||||||||||||||||||
| 192 | - | |||||||||||||||||||
| 193 | - | |||||||||||||||||||
| 194 | - | |||||||||||||||||||
| 195 | static | - | ||||||||||||||||||
| 196 | _Bool | - | ||||||||||||||||||
| 197 | - | |||||||||||||||||||
| 198 | no_leading_hyphen (char const *file) | - | ||||||||||||||||||
| 199 | { | - | ||||||||||||||||||
| 200 | char const *p; | - | ||||||||||||||||||
| 201 | - | |||||||||||||||||||
| 202 | for (p = file; (
| 1-2 | ||||||||||||||||||
| 203 | (__extension__ (__builtin_constant_p (
| 0-2 | ||||||||||||||||||
| 204 | '-'
| 0-2 | ||||||||||||||||||
| 205 | )
| 0-2 | ||||||||||||||||||
| 206 | p
| 0-2 | ||||||||||||||||||
| 207 | )
| 0-2 | ||||||||||||||||||
| 208 | '-'
| 0-2 | ||||||||||||||||||
| 209 | ) == '\0'
| 0-2 | ||||||||||||||||||
| 210 | p
| 1-2 | ||||||||||||||||||
| 211 | ,
| 1-2 | ||||||||||||||||||
| 212 | '-'
| 1-2 | ||||||||||||||||||
| 213 | ) : __builtin_strchr (
| 1-2 | ||||||||||||||||||
| 214 | p
| 1-2 | ||||||||||||||||||
| 215 | ,
| 1-2 | ||||||||||||||||||
| 216 | '-'
| 1-2 | ||||||||||||||||||
| 217 | )))
| 1-2 | ||||||||||||||||||
| 218 | )
| 1-2 | ||||||||||||||||||
| 219 | if (p == file
| 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:
executed 2 times by 1 test: return 0 ;Executed by:
| 2 | ||||||||||||||||||
| 228 | 0 executed 2 times by 1 test: return 0 ;Executed by:
| 2 | ||||||||||||||||||
| 229 | ; executed 2 times by 1 test: return 0 ;Executed by:
| 2 | ||||||||||||||||||
| 230 | } | - | ||||||||||||||||||
| 231 | - | |||||||||||||||||||
| 232 | return executed 1 time by 1 test: return 1 ;Executed by:
executed 1 time by 1 test: return 1 ;Executed by:
| 1 | ||||||||||||||||||
| 233 | 1 executed 1 time by 1 test: return 1 ;Executed by:
| 1 | ||||||||||||||||||
| 234 | ; executed 1 time by 1 test: return 1 ;Executed by:
| 1 | ||||||||||||||||||
| 235 | } | - | ||||||||||||||||||
| 236 | - | |||||||||||||||||||
| 237 | - | |||||||||||||||||||
| 238 | - | |||||||||||||||||||
| 239 | - | |||||||||||||||||||
| 240 | static | - | ||||||||||||||||||
| 241 | _Bool | - | ||||||||||||||||||
| 242 | - | |||||||||||||||||||
| 243 | portable_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 (*
| 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 | - | |||||||||||||||||||
| 287 | static char * | - | ||||||||||||||||||
| 288 | __attribute__ ((__pure__)) | - | ||||||||||||||||||
| 289 | - | |||||||||||||||||||
| 290 | component_start (char *f) | - | ||||||||||||||||||
| 291 | { | - | ||||||||||||||||||
| 292 | while (*
| 0 | ||||||||||||||||||
| 293 | f++; never executed: f++; | 0 | ||||||||||||||||||
| 294 | return never executed: f;return f;never executed: return f; | 0 | ||||||||||||||||||
| 295 | } | - | ||||||||||||||||||
| 296 | - | |||||||||||||||||||
| 297 | - | |||||||||||||||||||
| 298 | - | |||||||||||||||||||
| 299 | static size_t | - | ||||||||||||||||||
| 300 | __attribute__ ((__pure__)) | - | ||||||||||||||||||
| 301 | - | |||||||||||||||||||
| 302 | component_len (char const *f) | - | ||||||||||||||||||
| 303 | { | - | ||||||||||||||||||
| 304 | size_t len; | - | ||||||||||||||||||
| 305 | for (len = 1; f[len] != '/'
| 0 | ||||||||||||||||||
| 306 | continue; never executed: continue; | 0 | ||||||||||||||||||
| 307 | return never executed: len;return len;never executed: return len; | 0 | ||||||||||||||||||
| 308 | } | - | ||||||||||||||||||
| 309 | static | - | ||||||||||||||||||
| 310 | _Bool | - | ||||||||||||||||||
| 311 | - | |||||||||||||||||||
| 312 | validate_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
| 1-3 | ||||||||||||||||||
| 337 | return executed 2 times by 1 test: return 0 ;Executed by:
executed 2 times by 1 test: return 0 ;Executed by:
| 2 | ||||||||||||||||||
| 338 | 0 executed 2 times by 1 test: return 0 ;Executed by:
| 2 | ||||||||||||||||||
| 339 | ; executed 2 times by 1 test: return 0 ;Executed by:
| 2 | ||||||||||||||||||
| 340 | - | |||||||||||||||||||
| 341 | if ((check_basic_portability
| 1-3 | ||||||||||||||||||
| 342 | && filelen == 0
| 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:
executed 2 times by 1 test: return 0 ;Executed by:
| 2 | ||||||||||||||||||
| 354 | 0 executed 2 times by 1 test: return 0 ;Executed by:
| 2 | ||||||||||||||||||
| 355 | ; executed 2 times by 1 test: return 0 ;Executed by:
| 2 | ||||||||||||||||||
| 356 | } | - | ||||||||||||||||||
| 357 | - | |||||||||||||||||||
| 358 | if (check_basic_portability
| 0-2 | ||||||||||||||||||
| 359 | { | - | ||||||||||||||||||
| 360 | if (! portable_chars_only (file, filelen)
| 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
| 1 | ||||||||||||||||||
| 374 | file_exists = executed 1 time by 1 test: file_exists = 1 ;Executed by:
| 1 | ||||||||||||||||||
| 375 | 1 executed 1 time by 1 test: file_exists = 1 ;Executed by:
| 1 | ||||||||||||||||||
| 376 | ; executed 1 time by 1 test: file_exists = 1 ;Executed by:
| 1 | ||||||||||||||||||
| 377 | else if ( | - | ||||||||||||||||||
| 378 | (*
| 0-1 | ||||||||||||||||||
| 379 | !=
| 0-1 | ||||||||||||||||||
| 380 | 2
| 0-1 | ||||||||||||||||||
| 381 | || filelen == 0
| 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:
executed 1 time by 1 test: return 0 ;Executed by:
| 1 | ||||||||||||||||||
| 387 | 0 executed 1 time by 1 test: return 0 ;Executed by:
| 1 | ||||||||||||||||||
| 388 | ; executed 1 time by 1 test: return 0 ;Executed by:
| 1 | ||||||||||||||||||
| 389 | } | - | ||||||||||||||||||
| 390 | } executed 1 time by 1 test: end of blockExecuted by:
| 1 | ||||||||||||||||||
| 391 | - | |||||||||||||||||||
| 392 | if (check_basic_portability
| 0-1 | ||||||||||||||||||
| 393 | || (! file_exists
| 0-1 | ||||||||||||||||||
| 394 | 256
| 0 | ||||||||||||||||||
| 395 | <= filelen
| 0 | ||||||||||||||||||
| 396 | { | - | ||||||||||||||||||
| 397 | size_t maxsize; | - | ||||||||||||||||||
| 398 | - | |||||||||||||||||||
| 399 | if (check_basic_portability
| 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 = (*
| 0 | ||||||||||||||||||
| 407 | - | |||||||||||||||||||
| 408 | (*__errno_location ()) | - | ||||||||||||||||||
| 409 | = 0; | - | ||||||||||||||||||
| 410 | size = pathconf (dir, | - | ||||||||||||||||||
| 411 | _PC_PATH_MAX | - | ||||||||||||||||||
| 412 | ); | - | ||||||||||||||||||
| 413 | if (size < 0
| 0 | ||||||||||||||||||
| 414 | (*
| 0 | ||||||||||||||||||
| 415 | != 0
| 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 | (((
| 0 | ||||||||||||||||||
| 432 | size
| 0 | ||||||||||||||||||
| 433 | )<(0x7fffffffffffffffL))
| 0 | ||||||||||||||||||
| 434 | size | - | ||||||||||||||||||
| 435 | ):(0x7fffffffffffffffL)) | - | ||||||||||||||||||
| 436 | ; | - | ||||||||||||||||||
| 437 | } never executed: end of block | 0 | ||||||||||||||||||
| 438 | - | |||||||||||||||||||
| 439 | if (maxsize <= filelen
| 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
| 0-1 | ||||||||||||||||||
| 462 | { | - | ||||||||||||||||||
| 463 | for (start = file; *(
| 0 | ||||||||||||||||||
| 464 | { | - | ||||||||||||||||||
| 465 | size_t length = component_len (start); | - | ||||||||||||||||||
| 466 | - | |||||||||||||||||||
| 467 | if ( | - | ||||||||||||||||||
| 468 | 14
| 0 | ||||||||||||||||||
| 469 | < length
| 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
| 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
| 0 | ||||||||||||||||||
| 493 | 14 | - | ||||||||||||||||||
| 494 | : 0); | - | ||||||||||||||||||
| 495 | - | |||||||||||||||||||
| 496 | for (start = file; *(
| 0 | ||||||||||||||||||
| 497 | { | - | ||||||||||||||||||
| 498 | size_t length; | - | ||||||||||||||||||
| 499 | - | |||||||||||||||||||
| 500 | if (known_name_max
| 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
| 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 | ||||||||||||||||||
| 516 | name_max = never executed: name_max = ((( len )<(0x7fffffffffffffffL))?( len ):(0x7fffffffffffffffL)) ; | 0 | ||||||||||||||||||
| 517 | (((
never executed: name_max = ((( len )<(0x7fffffffffffffffL))?( len ):(0x7fffffffffffffffL)) ; | 0 | ||||||||||||||||||
| 518 | len
never executed: name_max = ((( len )<(0x7fffffffffffffffL))?( len ):(0x7fffffffffffffffL)) ; | 0 | ||||||||||||||||||
| 519 | )<(0x7fffffffffffffffL))
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: 0:case 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
| 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:
executed 1 time by 1 test: return 1 ;Executed by:
| 1 | ||||||||||||||||||
| 581 | 1 executed 1 time by 1 test: return 1 ;Executed by:
| 1 | ||||||||||||||||||
| 582 | ; executed 1 time by 1 test: return 1 ;Executed by:
| 1 | ||||||||||||||||||
| 583 | } | - | ||||||||||||||||||
| Switch to Source code | Preprocessed file |