clang -cc1 -cc1 -triple amd64-unknown-openbsd7.0 -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name getconf.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 1 -pic-is-pie -mframe-pointer=all -relaxed-aliasing -fno-rounding-math -mconstructor-aliases -munwind-tables -target-cpu x86-64 -target-feature +retpoline-indirect-calls -target-feature +retpoline-indirect-branches -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/usr/src/usr.bin/getconf/obj -resource-dir /usr/local/lib/clang/13.0.0 -internal-isystem /usr/local/lib/clang/13.0.0/include -internal-externc-isystem /usr/include -O2 -fdebug-compilation-dir=/usr/src/usr.bin/getconf/obj -ferror-limit 19 -fwrapv -D_RET_PROTECTOR -ret-protector -fgnuc-version=4.2.1 -vectorize-loops -vectorize-slp -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-valloc -fno-builtin-free -fno-builtin-strdup -fno-builtin-strndup -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /home/ben/Projects/vmm/scan-build/2022-01-12-194120-40624-1 -x c /usr/src/usr.bin/getconf/getconf.c
| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | |
| 16 | |
| 17 | |
| 18 | |
| 19 | |
| 20 | |
| 21 | |
| 22 | |
| 23 | |
| 24 | |
| 25 | |
| 26 | |
| 27 | |
| 28 | |
| 29 | |
| 30 | |
| 31 | |
| 32 | |
| 33 | |
| 34 | |
| 35 | |
| 36 | |
| 37 | |
| 38 | |
| 39 | |
| 40 | |
| 41 | |
| 42 | |
| 43 | #include <err.h> |
| 44 | #include <errno.h> |
| 45 | #include <limits.h> |
| 46 | #include <stdio.h> |
| 47 | #include <stdlib.h> |
| 48 | #include <string.h> |
| 49 | #include <unistd.h> |
| 50 | |
| 51 | static void __dead usage(void); |
| 52 | static void list_var(int); |
| 53 | static int compilation_spec_valid(const char *); |
| 54 | |
| 55 | struct conf_variable |
| 56 | { |
| 57 | const char *name; |
| 58 | enum { SYSCONF, CONFSTR, PATHCONF, CONSTANT } type; |
| 59 | long value; |
| 60 | }; |
| 61 | |
| 62 | |
| 63 | #define constant_row(name) { #name, CONSTANT, name }, |
| 64 | #define sysconf_row(name) { #name, SYSCONF, _SC_##name }, |
| 65 | #define pathconf_row(name) { #name, PATHCONF, _PC_##name }, |
| 66 | #define confstr_row(name) { #name, CONFSTR, _CS_##name }, |
| 67 | #define posix_constant_row(name) { #name, CONSTANT, _POSIX_##name }, |
| 68 | #define posix_confstr_row(name) { #name, CONFSTR, _CS_POSIX_##name }, |
| 69 | #define compat_posix2_sysconf_row(name) { #name, SYSCONF, _SC_2_##name }, |
| 70 | #define compat_posix2_constant_row(name) { #name, CONSTANT, _POSIX2_##name }, |
| 71 | |
| 72 | |
| 73 | #define posix2_sysconf_row(name) \ |
| 74 | { "_POSIX2_" #name, SYSCONF, _SC_2_##name }, |
| 75 | #define posix2_pathconf_row(name) \ |
| 76 | { "_POSIX2_" #name, PATHCONF, _PC_2_##name }, |
| 77 | #define pthread_sysconf_row(name) \ |
| 78 | { "_PTHREAD_" #name, SYSCONF, _SC_THREAD_##name }, |
| 79 | #define xopen_sysconf_row(name) \ |
| 80 | { "_XOPEN_" #name, SYSCONF, _SC_XOPEN_##name }, |
| 81 | |
| 82 | const struct conf_variable conf_table[] = |
| 83 | { |
| 84 | |
| 85 | confstr_row(PATH) |
| 86 | confstr_row(V7_ENV) |
| 87 | confstr_row(V6_ENV) |
| 88 | |
| 89 | |
| 90 | sysconf_row(BC_BASE_MAX) |
| 91 | sysconf_row(BC_DIM_MAX) |
| 92 | sysconf_row(BC_SCALE_MAX) |
| 93 | sysconf_row(BC_STRING_MAX) |
| 94 | sysconf_row(COLL_WEIGHTS_MAX) |
| 95 | sysconf_row(EXPR_NEST_MAX) |
| 96 | sysconf_row(LINE_MAX) |
| 97 | sysconf_row(RE_DUP_MAX) |
| 98 | |
| 99 | |
| 100 | sysconf_row(AIO_LISTIO_MAX) |
| 101 | sysconf_row(AIO_MAX) |
| 102 | sysconf_row(AIO_PRIO_DELTA_MAX) |
| 103 | sysconf_row(ARG_MAX) |
| 104 | sysconf_row(CHILD_MAX) |
| 105 | sysconf_row(CLK_TCK) |
| 106 | sysconf_row(NGROUPS_MAX) |
| 107 | sysconf_row(OPEN_MAX) |
| 108 | sysconf_row(STREAM_MAX) |
| 109 | sysconf_row(TZNAME_MAX) |
| 110 | sysconf_row(PAGE_SIZE) |
| 111 | sysconf_row(PAGESIZE) |
| 112 | |
| 113 | sysconf_row(SEM_NSEMS_MAX) |
| 114 | sysconf_row(SEM_VALUE_MAX) |
| 115 | sysconf_row(HOST_NAME_MAX) |
| 116 | sysconf_row(LOGIN_NAME_MAX) |
| 117 | |
| 118 | sysconf_row(ATEXIT_MAX) |
| 119 | sysconf_row(DELAYTIMER_MAX) |
| 120 | sysconf_row(IOV_MAX) |
| 121 | sysconf_row(MQ_OPEN_MAX) |
| 122 | sysconf_row(MQ_PRIO_MAX) |
| 123 | sysconf_row(RTSIG_MAX) |
| 124 | sysconf_row(SIGQUEUE_MAX) |
| 125 | sysconf_row(SYMLOOP_MAX) |
| 126 | sysconf_row(TIMER_MAX) |
| 127 | sysconf_row(TTY_NAME_MAX) |
| 128 | |
| 129 | posix2_sysconf_row(PBS) |
| 130 | posix2_sysconf_row(PBS_ACCOUNTING) |
| 131 | posix2_sysconf_row(PBS_CHECKPOINT) |
| 132 | posix2_sysconf_row(PBS_LOCATE) |
| 133 | posix2_sysconf_row(PBS_MESSAGE) |
| 134 | posix2_sysconf_row(PBS_TRACK) |
| 135 | |
| 136 | pthread_sysconf_row(DESTRUCTOR_ITERATIONS) |
| 137 | pthread_sysconf_row(KEYS_MAX) |
| 138 | pthread_sysconf_row(STACK_MIN) |
| 139 | pthread_sysconf_row(THREADS_MAX) |
| 140 | |
| 141 | xopen_sysconf_row(SHM) |
| 142 | xopen_sysconf_row(CRYPT) |
| 143 | xopen_sysconf_row(ENH_I18N) |
| 144 | xopen_sysconf_row(REALTIME) |
| 145 | xopen_sysconf_row(REALTIME_THREADS) |
| 146 | xopen_sysconf_row(STREAMS) |
| 147 | xopen_sysconf_row(UNIX) |
| 148 | xopen_sysconf_row(UUCP) |
| 149 | xopen_sysconf_row(VERSION) |
| 150 | |
| 151 | pathconf_row(FILESIZEBITS) |
| 152 | pathconf_row(LINK_MAX) |
| 153 | pathconf_row(MAX_CANON) |
| 154 | pathconf_row(MAX_INPUT) |
| 155 | pathconf_row(NAME_MAX) |
| 156 | pathconf_row(PATH_MAX) |
| 157 | pathconf_row(PIPE_BUF) |
| 158 | pathconf_row(SYMLINK_MAX) |
| 159 | |
| 160 | posix2_pathconf_row(SYMLINKS) |
| 161 | |
| 162 | constant_row(_POSIX2_CHARCLASS_NAME_MAX) |
| 163 | constant_row(_XOPEN_IOV_MAX) |
| 164 | constant_row(_XOPEN_NAME_MAX) |
| 165 | constant_row(_XOPEN_PATH_MAX) |
| 166 | |
| 167 | |
| 168 | sysconf_row(PHYS_PAGES) |
| 169 | sysconf_row(AVPHYS_PAGES) |
| 170 | sysconf_row(NPROCESSORS_CONF) |
| 171 | sysconf_row(NPROCESSORS_ONLN) |
| 172 | |
| 173 | { NULL } |
| 174 | }; |
| 175 | |
| 176 | |
| 177 | |
| 178 | |
| 179 | |
| 180 | const char uposix_prefix[] = "_POSIX_"; |
| 181 | const struct conf_variable uposix_conf_table[] = |
| 182 | { |
| 183 | |
| 184 | posix_constant_row(CLOCKRES_MIN) |
| 185 | |
| 186 | |
| 187 | |
| 188 | |
| 189 | posix_constant_row(ARG_MAX) |
| 190 | posix_constant_row(CHILD_MAX) |
| 191 | |
| 192 | posix_constant_row(HOST_NAME_MAX) |
| 193 | posix_constant_row(LINK_MAX) |
| 194 | posix_constant_row(LOGIN_NAME_MAX) |
| 195 | posix_constant_row(MAX_CANON) |
| 196 | posix_constant_row(MAX_INPUT) |
| 197 | |
| 198 | |
| 199 | posix_constant_row(NAME_MAX) |
| 200 | posix_constant_row(NGROUPS_MAX) |
| 201 | posix_constant_row(OPEN_MAX) |
| 202 | posix_constant_row(PATH_MAX) |
| 203 | posix_constant_row(PIPE_BUF) |
| 204 | posix_constant_row(RE_DUP_MAX) |
| 205 | |
| 206 | posix_constant_row(SEM_NSEMS_MAX) |
| 207 | posix_constant_row(SEM_VALUE_MAX) |
| 208 | |
| 209 | posix_constant_row(SSIZE_MAX) |
| 210 | |
| 211 | posix_constant_row(STREAM_MAX) |
| 212 | posix_constant_row(SYMLINK_MAX) |
| 213 | posix_constant_row(SYMLOOP_MAX) |
| 214 | posix_constant_row(THREAD_DESTRUCTOR_ITERATIONS) |
| 215 | posix_constant_row(THREAD_KEYS_MAX) |
| 216 | posix_constant_row(THREAD_THREADS_MAX) |
| 217 | |
| 218 | posix_constant_row(TTY_NAME_MAX) |
| 219 | posix_constant_row(TZNAME_MAX) |
| 220 | |
| 221 | |
| 222 | sysconf_row(JOB_CONTROL) |
| 223 | sysconf_row(SAVED_IDS) |
| 224 | sysconf_row(VERSION) |
| 225 | sysconf_row(FSYNC) |
| 226 | sysconf_row(MONOTONIC_CLOCK) |
| 227 | sysconf_row(THREAD_SAFE_FUNCTIONS) |
| 228 | sysconf_row(ADVISORY_INFO) |
| 229 | sysconf_row(BARRIERS) |
| 230 | sysconf_row(ASYNCHRONOUS_IO) |
| 231 | sysconf_row(CLOCK_SELECTION) |
| 232 | sysconf_row(CPUTIME) |
| 233 | sysconf_row(IPV6) |
| 234 | sysconf_row(MAPPED_FILES) |
| 235 | sysconf_row(MEMLOCK) |
| 236 | sysconf_row(MEMLOCK_RANGE) |
| 237 | sysconf_row(MEMORY_PROTECTION) |
| 238 | sysconf_row(MESSAGE_PASSING) |
| 239 | sysconf_row(PRIORITIZED_IO) |
| 240 | sysconf_row(PRIORITY_SCHEDULING) |
| 241 | sysconf_row(RAW_SOCKETS) |
| 242 | sysconf_row(READER_WRITER_LOCKS) |
| 243 | sysconf_row(REALTIME_SIGNALS) |
| 244 | sysconf_row(REGEXP) |
| 245 | sysconf_row(SEMAPHORES) |
| 246 | sysconf_row(SHARED_MEMORY_OBJECTS) |
| 247 | sysconf_row(SHELL) |
| 248 | sysconf_row(SPAWN) |
| 249 | sysconf_row(SPIN_LOCKS) |
| 250 | sysconf_row(SPORADIC_SERVER) |
| 251 | sysconf_row(SS_REPL_MAX) |
| 252 | sysconf_row(SYNCHRONIZED_IO) |
| 253 | sysconf_row(THREAD_ATTR_STACKADDR) |
| 254 | sysconf_row(THREAD_ATTR_STACKSIZE) |
| 255 | sysconf_row(THREAD_CPUTIME) |
| 256 | sysconf_row(THREAD_PRIO_INHERIT) |
| 257 | sysconf_row(THREAD_PRIO_PROTECT) |
| 258 | sysconf_row(THREAD_PRIORITY_SCHEDULING) |
| 259 | sysconf_row(THREAD_PROCESS_SHARED) |
| 260 | sysconf_row(THREAD_ROBUST_PRIO_INHERIT) |
| 261 | sysconf_row(THREAD_SPORADIC_SERVER) |
| 262 | sysconf_row(THREADS) |
| 263 | sysconf_row(TIMEOUTS) |
| 264 | sysconf_row(TIMERS) |
| 265 | sysconf_row(TRACE) |
| 266 | sysconf_row(TRACE_EVENT_FILTER) |
| 267 | sysconf_row(TRACE_EVENT_NAME_MAX) |
| 268 | sysconf_row(TRACE_INHERIT) |
| 269 | sysconf_row(TRACE_LOG) |
| 270 | sysconf_row(TRACE_NAME_MAX) |
| 271 | sysconf_row(TRACE_SYS_MAX) |
| 272 | sysconf_row(TRACE_USER_EVENT_MAX) |
| 273 | sysconf_row(TYPED_MEMORY_OBJECTS) |
| 274 | |
| 275 | |
| 276 | |
| 277 | |
| 278 | |
| 279 | sysconf_row(V7_ILP32_OFF32) |
| 280 | sysconf_row(V7_ILP32_OFFBIG) |
| 281 | sysconf_row(V7_LP64_OFF64) |
| 282 | sysconf_row(V7_LPBIG_OFFBIG) |
| 283 | sysconf_row(V6_ILP32_OFF32) |
| 284 | sysconf_row(V6_ILP32_OFFBIG) |
| 285 | sysconf_row(V6_LP64_OFF64) |
| 286 | sysconf_row(V6_LPBIG_OFFBIG) |
| 287 | |
| 288 | |
| 289 | pathconf_row(CHOWN_RESTRICTED) |
| 290 | pathconf_row(NO_TRUNC) |
| 291 | pathconf_row(VDISABLE) |
| 292 | pathconf_row(ASYNC_IO) |
| 293 | pathconf_row(PRIO_IO) |
| 294 | pathconf_row(SYNC_IO) |
| 295 | pathconf_row(TIMESTAMP_RESOLUTION) |
| 296 | |
| 297 | { NULL } |
| 298 | }; |
| 299 | |
| 300 | |
| 301 | |
| 302 | |
| 303 | const char posix_prefix[] = "POSIX_"; |
| 304 | const struct conf_variable posix_conf_table[] = |
| 305 | { |
| 306 | pathconf_row(ALLOC_SIZE_MIN) |
| 307 | pathconf_row(REC_INCR_XFER_SIZE) |
| 308 | pathconf_row(REC_MAX_XFER_SIZE) |
| 309 | pathconf_row(REC_MIN_XFER_SIZE) |
| 310 | pathconf_row(REC_XFER_ALIGN) |
| 311 | |
| 312 | posix_confstr_row(V7_ILP32_OFF32_CFLAGS) |
| 313 | posix_confstr_row(V7_ILP32_OFF32_LDFLAGS) |
| 314 | posix_confstr_row(V7_ILP32_OFF32_LIBS) |
| 315 | posix_confstr_row(V7_ILP32_OFFBIG_CFLAGS) |
| 316 | posix_confstr_row(V7_ILP32_OFFBIG_LDFLAGS) |
| 317 | posix_confstr_row(V7_ILP32_OFFBIG_LIBS) |
| 318 | posix_confstr_row(V7_LP64_OFF64_CFLAGS) |
| 319 | posix_confstr_row(V7_LP64_OFF64_LDFLAGS) |
| 320 | posix_confstr_row(V7_LP64_OFF64_LIBS) |
| 321 | posix_confstr_row(V7_LPBIG_OFFBIG_CFLAGS) |
| 322 | posix_confstr_row(V7_LPBIG_OFFBIG_LDFLAGS) |
| 323 | posix_confstr_row(V7_LPBIG_OFFBIG_LIBS) |
| 324 | posix_confstr_row(V7_THREADS_CFLAGS) |
| 325 | posix_confstr_row(V7_THREADS_LDFLAGS) |
| 326 | posix_confstr_row(V7_WIDTH_RESTRICTED_ENVS) |
| 327 | posix_confstr_row(V6_ILP32_OFF32_CFLAGS) |
| 328 | posix_confstr_row(V6_ILP32_OFF32_LDFLAGS) |
| 329 | posix_confstr_row(V6_ILP32_OFF32_LIBS) |
| 330 | posix_confstr_row(V6_ILP32_OFFBIG_CFLAGS) |
| 331 | posix_confstr_row(V6_ILP32_OFFBIG_LDFLAGS) |
| 332 | posix_confstr_row(V6_ILP32_OFFBIG_LIBS) |
| 333 | posix_confstr_row(V6_LP64_OFF64_CFLAGS) |
| 334 | posix_confstr_row(V6_LP64_OFF64_LDFLAGS) |
| 335 | posix_confstr_row(V6_LP64_OFF64_LIBS) |
| 336 | posix_confstr_row(V6_LPBIG_OFFBIG_CFLAGS) |
| 337 | posix_confstr_row(V6_LPBIG_OFFBIG_LDFLAGS) |
| 338 | posix_confstr_row(V6_LPBIG_OFFBIG_LIBS) |
| 339 | posix_confstr_row(V6_WIDTH_RESTRICTED_ENVS) |
| 340 | |
| 341 | { NULL } |
| 342 | }; |
| 343 | |
| 344 | |
| 345 | |
| 346 | |
| 347 | |
| 348 | const char compat_posix2_prefix[] = "POSIX2_"; |
| 349 | const struct conf_variable compat_posix2_conf_table[] = |
| 350 | { |
| 351 | |
| 352 | compat_posix2_sysconf_row(VERSION) |
| 353 | compat_posix2_sysconf_row(C_BIND) |
| 354 | compat_posix2_sysconf_row(C_DEV) |
| 355 | compat_posix2_sysconf_row(CHAR_TERM) |
| 356 | compat_posix2_sysconf_row(FORT_DEV) |
| 357 | compat_posix2_sysconf_row(FORT_RUN) |
| 358 | compat_posix2_sysconf_row(LOCALEDEF) |
| 359 | compat_posix2_sysconf_row(SW_DEV) |
| 360 | compat_posix2_sysconf_row(UPE) |
| 361 | |
| 362 | |
| 363 | compat_posix2_constant_row(BC_BASE_MAX) |
| 364 | compat_posix2_constant_row(BC_DIM_MAX) |
| 365 | compat_posix2_constant_row(BC_SCALE_MAX) |
| 366 | compat_posix2_constant_row(BC_STRING_MAX) |
| 367 | compat_posix2_constant_row(COLL_WEIGHTS_MAX) |
| 368 | compat_posix2_constant_row(EXPR_NEST_MAX) |
| 369 | compat_posix2_constant_row(LINE_MAX) |
| 370 | compat_posix2_constant_row(RE_DUP_MAX) |
| 371 | |
| 372 | { NULL } |
| 373 | }; |
| 374 | |
| 375 | #undef constant_row |
| 376 | #undef sysconf_row |
| 377 | #undef pathconf_row |
| 378 | #undef confstr_row |
| 379 | #undef posix_constant_row |
| 380 | #undef posix_confstr_row |
| 381 | #undef compat_posix2_sysconf_row |
| 382 | #undef compat_posix2_constant_row |
| 383 | |
| 384 | |
| 385 | |
| 386 | |
| 387 | |
| 388 | |
| 389 | const char *compilation_specs[] = { |
| 390 | "V7_ILP32_OFF32", |
| 391 | "V7_ILP32_OFFBIG", |
| 392 | "V7_LP64_OFF64", |
| 393 | "V7_LPBIG_OFFBIG", |
| 394 | "V6_ILP32_OFF32", |
| 395 | "V6_ILP32_OFFBIG", |
| 396 | "V6_LP64_OFF64", |
| 397 | "V6_LPBIG_OFFBIG", |
| 398 | NULL |
| 399 | }; |
| 400 | |
| 401 | int |
| 402 | main(int argc, char *argv[]) |
| 403 | { |
| 404 | int ch; |
| 405 | const struct conf_variable *cp; |
| 406 | |
| 407 | long val; |
| 408 | size_t slen; |
| 409 | char * sval; |
| 410 | |
| 411 | while ((ch = getopt(argc, argv, "lLv:")) != -1) { |
| 1 | Assuming the condition is false | |
|
| 2 | | Loop condition is false. Execution continues on line 428 | |
|
| 412 | switch (ch) { |
| 413 | case 'l': |
| 414 | list_var(0); |
| 415 | return (0); |
| 416 | case 'L': |
| 417 | list_var(1); |
| 418 | return (0); |
| 419 | case 'v': |
| 420 | if (! compilation_spec_valid(optarg)) |
| 421 | errx(1, "%s: unknown specification", optarg); |
| 422 | break; |
| 423 | case '?': |
| 424 | default: |
| 425 | usage(); |
| 426 | } |
| 427 | } |
| 428 | argc -= optind; |
| 429 | argv += optind; |
| 430 | |
| 431 | if (argc < 1 || argc > 2) |
| |
| |
| |
| 432 | usage(); |
| 433 | |
| 434 | |
| 435 | if (strncmp(*argv, uposix_prefix, sizeof(uposix_prefix) - 1) == 0) { |
| |
| 436 | cp = uposix_conf_table; |
| 437 | slen = sizeof(uposix_prefix) - 1; |
| 438 | } else if (strncmp(*argv, posix_prefix, |
| 439 | sizeof(posix_prefix) - 1) == 0) { |
| 440 | cp = posix_conf_table; |
| 441 | slen = sizeof(posix_prefix) - 1; |
| 442 | } else { |
| 443 | cp = conf_table; |
| 444 | slen = 0; |
| 445 | } |
| 446 | |
| 447 | |
| 448 | for (; cp->name != NULL; cp++) |
| 7 | | Assuming field 'name' is not equal to NULL | |
|
| 8 | | Loop condition is true. Entering loop body | |
|
| 449 | if (strcmp(*argv + slen, cp->name) == 0) |
| |
| 450 | break; |
| 10 | | Execution continues on line 457 | |
|
| 451 | |
| 452 | |
| 453 | |
| 454 | |
| 455 | |
| 456 | |
| 457 | slen = argv[0][0] == '_'; |
| 458 | if (cp->name == NULL && strncmp(*argv + slen, compat_posix2_prefix, |
| 459 | sizeof(compat_posix2_prefix) - 1) == 0) { |
| 460 | slen += sizeof(compat_posix2_prefix) - 1; |
| 461 | for (cp = compat_posix2_conf_table; cp->name != NULL; cp++) { |
| 462 | if (strcmp(*argv + slen, cp->name) == 0) |
| 463 | break; |
| 464 | } |
| 465 | } |
| 466 | |
| 467 | if (cp->name == NULL) |
| |
| 468 | errx(1, "%s: unknown variable", *argv); |
| 469 | |
| 470 | if (cp->type == PATHCONF) { |
| 12 | | Assuming field 'type' is not equal to PATHCONF | |
|
| |
| 471 | if (argc != 2) usage(); |
| 472 | } else { |
| 473 | if (argc != 1) usage(); |
| 14 | | Assuming 'argc' is equal to 1 | |
|
| |
| 474 | } |
| 475 | |
| 476 | switch (cp->type) { |
| 16 | | Control jumps to 'case CONFSTR:' at line 483 | |
|
| 477 | case CONSTANT: |
| 478 | if (pledge("stdio", NULL) == -1) |
| 479 | err(1, "pledge"); |
| 480 | printf("%ld\n", cp->value); |
| 481 | break; |
| 482 | |
| 483 | case CONFSTR: |
| 484 | if (pledge("stdio", NULL) == -1) |
| 17 | | Assuming the condition is false | |
|
| |
| 485 | err(1, "pledge"); |
| 486 | errno = 0; |
| 487 | if ((slen = confstr(cp->value, NULL, 0)) == 0) { |
| 19 | | Assuming the condition is false | |
|
| |
| 488 | if (errno != 0) |
| 489 | err(1, NULL); |
| 490 | |
| 491 | printf("undefined\n"); |
| 492 | } else { |
| 493 | if ((sval = malloc(slen)) == NULL) |
| |
| 22 | | Assuming the condition is false | |
|
| |
| 494 | err(1, NULL); |
| 495 | |
| 496 | confstr(cp->value, sval, slen); |
| 497 | printf("%s\n", sval); |
| 498 | } |
| 499 | break; |
| 24 | | Execution continues on line 532 | |
|
| 500 | |
| 501 | case SYSCONF: |
| 502 | if (pledge("stdio inet ps vminfo", NULL) == -1) |
| 503 | err(1, "pledge"); |
| 504 | errno = 0; |
| 505 | if ((val = sysconf(cp->value)) == -1) { |
| 506 | if (errno != 0) |
| 507 | err(1, NULL); |
| 508 | |
| 509 | printf("undefined\n"); |
| 510 | } else { |
| 511 | printf("%ld\n", val); |
| 512 | } |
| 513 | break; |
| 514 | |
| 515 | case PATHCONF: |
| 516 | if (unveil(argv[1], "r") == -1) |
| 517 | err(1, "unveil %s", argv[1]); |
| 518 | if (pledge("stdio rpath", NULL) == -1) |
| 519 | err(1, "pledge"); |
| 520 | errno = 0; |
| 521 | if ((val = pathconf(argv[1], cp->value)) == -1) { |
| 522 | if (errno != 0) |
| 523 | err(1, "%s", argv[1]); |
| 524 | |
| 525 | printf("undefined\n"); |
| 526 | } else { |
| 527 | printf("%ld\n", val); |
| 528 | } |
| 529 | break; |
| 530 | } |
| 531 | |
| 532 | return ferror(stdout); |
| 25 | | Potential leak of memory pointed to by 'sval' |
|
| 533 | } |
| 534 | |
| 535 | |
| 536 | static void __dead |
| 537 | usage(void) |
| 538 | { |
| 539 | extern char *__progname; |
| 540 | |
| 541 | (void)fprintf(stderr, |
| 542 | "usage: %s [-Ll] [-v specification] name [pathname]\n", |
| 543 | __progname); |
| 544 | exit(1); |
| 545 | } |
| 546 | |
| 547 | static void |
| 548 | list_var(int do_pathconf) |
| 549 | { |
| 550 | const struct conf_variable *cp; |
| 551 | |
| 552 | for (cp = uposix_conf_table; cp->name != NULL; cp++) |
| 553 | if ((cp->type == PATHCONF) == do_pathconf) |
| 554 | printf("%s%s\n", uposix_prefix, cp->name); |
| 555 | for (cp = posix_conf_table; cp->name != NULL; cp++) |
| 556 | if ((cp->type == PATHCONF) == do_pathconf) |
| 557 | printf("%s%s\n", posix_prefix, cp->name); |
| 558 | for (cp = conf_table; cp->name != NULL; cp++) |
| 559 | if ((cp->type == PATHCONF) == do_pathconf) |
| 560 | printf("%s\n", cp->name); |
| 561 | for (cp = compat_posix2_conf_table; cp->name != NULL; cp++) |
| 562 | if ((cp->type == PATHCONF) == do_pathconf) |
| 563 | printf("_%s%s\n", compat_posix2_prefix, cp->name); |
| 564 | } |
| 565 | |
| 566 | static int |
| 567 | compilation_spec_valid(const char *spec) |
| 568 | { |
| 569 | const char **sp; |
| 570 | const struct conf_variable *cp; |
| 571 | |
| 572 | if (strncmp(spec, posix_prefix, sizeof(posix_prefix) - 1) != 0) |
| 573 | return (0); |
| 574 | |
| 575 | spec += sizeof(posix_prefix) - 1; |
| 576 | for (sp = compilation_specs; *sp != NULL; sp++) |
| 577 | if (strcmp(spec, *sp) == 0) |
| 578 | break; |
| 579 | if (*sp == NULL) |
| 580 | return (0); |
| 581 | |
| 582 | for (cp = uposix_conf_table; cp->name != NULL; cp++) |
| 583 | if (strcmp(spec, cp->name) == 0 && cp->type == SYSCONF) |
| 584 | return (sysconf(cp->value) != -1); |
| 585 | |
| 586 | return (0); |
| 587 | } |