Bug Summary

File:out/../deps/openssl/openssl/apps/lib/app_provider.c
Warning:line 70, column 15
Value stored to 'given' during its initialization is never read

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-unknown-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name app_provider.c -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 2 -pic-is-pie -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/home/maurizio/node-v18.6.0/out -resource-dir /usr/local/lib/clang/16.0.0 -D V8_DEPRECATION_WARNINGS -D V8_IMMINENT_DEPRECATION_WARNINGS -D _GLIBCXX_USE_CXX11_ABI=1 -D NODE_OPENSSL_CONF_NAME=nodejs_conf -D NODE_OPENSSL_HAS_QUIC -D __STDC_FORMAT_MACROS -D OPENSSL_NO_PINSHARED -D OPENSSL_THREADS -D OPENSSL_API_COMPAT=0x10100001L -D NDEBUG -D OPENSSL_USE_NODELETE -D L_ENDIAN -D OPENSSL_BUILDING_OPENSSL -D AES_ASM -D BSAES_ASM -D CMLL_ASM -D ECP_NISTZ256_ASM -D GHASH_ASM -D KECCAK1600_ASM -D MD5_ASM -D OPENSSL_BN_ASM_GF2m -D OPENSSL_BN_ASM_MONT -D OPENSSL_BN_ASM_MONT5 -D OPENSSL_CPUID_OBJ -D OPENSSL_IA32_SSE2 -D PADLOCK_ASM -D POLY1305_ASM -D SHA1_ASM -D SHA256_ASM -D SHA512_ASM -D VPAES_ASM -D WHIRLPOOL_ASM -D X25519_ASM -D OPENSSL_PIC -D OPENSSLDIR="/etc/ssl" -D ENGINESDIR="/dev/null" -D TERMIOS -I ../deps/openssl/openssl/apps/include -I ../deps/openssl/openssl -I ../deps/openssl/openssl/include -I ../deps/openssl/openssl/crypto -I ../deps/openssl/openssl/crypto/include -I ../deps/openssl/openssl/crypto/modes -I ../deps/openssl/openssl/crypto/ec/curve448 -I ../deps/openssl/openssl/crypto/ec/curve448/arch_32 -I ../deps/openssl/openssl/providers/common/include -I ../deps/openssl/openssl/providers/implementations/include -I ../deps/openssl/config -I ../deps/openssl/config/archs/linux-x86_64/asm/include -I ../deps/openssl/openssl/include -I ../deps/openssl/openssl/crypto/include -I ../deps/openssl/config/archs/linux-x86_64/asm -internal-isystem /usr/local/lib/clang/16.0.0/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-redhat-linux/8/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -O3 -Wno-unused-parameter -Wno-missing-field-initializers -Wno-old-style-declaration -fdebug-compilation-dir=/home/maurizio/node-v18.6.0/out -ferror-limit 19 -fgnuc-version=4.2.1 -vectorize-loops -vectorize-slp -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/scan-build-2022-08-22-142216-507842-1 -x c ../deps/openssl/openssl/apps/lib/app_provider.c
1/*
2 * Copyright 2020-2021 The OpenSSL Project Authors. All Rights Reserved.
3 *
4 * Licensed under the Apache License 2.0 (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
8 */
9
10#include "apps.h"
11#include <string.h>
12#include <openssl/err.h>
13#include <openssl/provider.h>
14#include <openssl/safestack.h>
15
16/* Non-zero if any of the provider options have been seen */
17static int provider_option_given = 0;
18
19DEFINE_STACK_OF(OSSL_PROVIDER)struct stack_st_OSSL_PROVIDER; typedef int (*sk_OSSL_PROVIDER_compfunc
)(const OSSL_PROVIDER * const *a, const OSSL_PROVIDER *const *
b); typedef void (*sk_OSSL_PROVIDER_freefunc)(OSSL_PROVIDER *
a); typedef OSSL_PROVIDER * (*sk_OSSL_PROVIDER_copyfunc)(const
OSSL_PROVIDER *a); static __attribute__((unused)) inline int
sk_OSSL_PROVIDER_num(const struct stack_st_OSSL_PROVIDER *sk
) { return OPENSSL_sk_num((const OPENSSL_STACK *)sk); } static
__attribute__((unused)) inline OSSL_PROVIDER *sk_OSSL_PROVIDER_value
(const struct stack_st_OSSL_PROVIDER *sk, int idx) { return (
OSSL_PROVIDER *)OPENSSL_sk_value((const OPENSSL_STACK *)sk, idx
); } static __attribute__((unused)) inline struct stack_st_OSSL_PROVIDER
*sk_OSSL_PROVIDER_new(sk_OSSL_PROVIDER_compfunc compare) { return
(struct stack_st_OSSL_PROVIDER *)OPENSSL_sk_new((OPENSSL_sk_compfunc
)compare); } static __attribute__((unused)) inline struct stack_st_OSSL_PROVIDER
*sk_OSSL_PROVIDER_new_null(void) { return (struct stack_st_OSSL_PROVIDER
*)OPENSSL_sk_new_null(); } static __attribute__((unused)) inline
struct stack_st_OSSL_PROVIDER *sk_OSSL_PROVIDER_new_reserve(
sk_OSSL_PROVIDER_compfunc compare, int n) { return (struct stack_st_OSSL_PROVIDER
*)OPENSSL_sk_new_reserve((OPENSSL_sk_compfunc)compare, n); }
static __attribute__((unused)) inline int sk_OSSL_PROVIDER_reserve
(struct stack_st_OSSL_PROVIDER *sk, int n) { return OPENSSL_sk_reserve
((OPENSSL_STACK *)sk, n); } static __attribute__((unused)) inline
void sk_OSSL_PROVIDER_free(struct stack_st_OSSL_PROVIDER *sk
) { OPENSSL_sk_free((OPENSSL_STACK *)sk); } static __attribute__
((unused)) inline void sk_OSSL_PROVIDER_zero(struct stack_st_OSSL_PROVIDER
*sk) { OPENSSL_sk_zero((OPENSSL_STACK *)sk); } static __attribute__
((unused)) inline OSSL_PROVIDER *sk_OSSL_PROVIDER_delete(struct
stack_st_OSSL_PROVIDER *sk, int i) { return (OSSL_PROVIDER *
)OPENSSL_sk_delete((OPENSSL_STACK *)sk, i); } static __attribute__
((unused)) inline OSSL_PROVIDER *sk_OSSL_PROVIDER_delete_ptr(
struct stack_st_OSSL_PROVIDER *sk, OSSL_PROVIDER *ptr) { return
(OSSL_PROVIDER *)OPENSSL_sk_delete_ptr((OPENSSL_STACK *)sk, (
const void *)ptr); } static __attribute__((unused)) inline int
sk_OSSL_PROVIDER_push(struct stack_st_OSSL_PROVIDER *sk, OSSL_PROVIDER
*ptr) { return OPENSSL_sk_push((OPENSSL_STACK *)sk, (const void
*)ptr); } static __attribute__((unused)) inline int sk_OSSL_PROVIDER_unshift
(struct stack_st_OSSL_PROVIDER *sk, OSSL_PROVIDER *ptr) { return
OPENSSL_sk_unshift((OPENSSL_STACK *)sk, (const void *)ptr); }
static __attribute__((unused)) inline OSSL_PROVIDER *sk_OSSL_PROVIDER_pop
(struct stack_st_OSSL_PROVIDER *sk) { return (OSSL_PROVIDER *
)OPENSSL_sk_pop((OPENSSL_STACK *)sk); } static __attribute__(
(unused)) inline OSSL_PROVIDER *sk_OSSL_PROVIDER_shift(struct
stack_st_OSSL_PROVIDER *sk) { return (OSSL_PROVIDER *)OPENSSL_sk_shift
((OPENSSL_STACK *)sk); } static __attribute__((unused)) inline
void sk_OSSL_PROVIDER_pop_free(struct stack_st_OSSL_PROVIDER
*sk, sk_OSSL_PROVIDER_freefunc freefunc) { OPENSSL_sk_pop_free
((OPENSSL_STACK *)sk, (OPENSSL_sk_freefunc)freefunc); } static
__attribute__((unused)) inline int sk_OSSL_PROVIDER_insert(struct
stack_st_OSSL_PROVIDER *sk, OSSL_PROVIDER *ptr, int idx) { return
OPENSSL_sk_insert((OPENSSL_STACK *)sk, (const void *)ptr, idx
); } static __attribute__((unused)) inline OSSL_PROVIDER *sk_OSSL_PROVIDER_set
(struct stack_st_OSSL_PROVIDER *sk, int idx, OSSL_PROVIDER *ptr
) { return (OSSL_PROVIDER *)OPENSSL_sk_set((OPENSSL_STACK *)sk
, idx, (const void *)ptr); } static __attribute__((unused)) inline
int sk_OSSL_PROVIDER_find(struct stack_st_OSSL_PROVIDER *sk,
OSSL_PROVIDER *ptr) { return OPENSSL_sk_find((OPENSSL_STACK *
)sk, (const void *)ptr); } static __attribute__((unused)) inline
int sk_OSSL_PROVIDER_find_ex(struct stack_st_OSSL_PROVIDER *
sk, OSSL_PROVIDER *ptr) { return OPENSSL_sk_find_ex((OPENSSL_STACK
*)sk, (const void *)ptr); } static __attribute__((unused)) inline
int sk_OSSL_PROVIDER_find_all(struct stack_st_OSSL_PROVIDER *
sk, OSSL_PROVIDER *ptr, int *pnum) { return OPENSSL_sk_find_all
((OPENSSL_STACK *)sk, (const void *)ptr, pnum); } static __attribute__
((unused)) inline void sk_OSSL_PROVIDER_sort(struct stack_st_OSSL_PROVIDER
*sk) { OPENSSL_sk_sort((OPENSSL_STACK *)sk); } static __attribute__
((unused)) inline int sk_OSSL_PROVIDER_is_sorted(const struct
stack_st_OSSL_PROVIDER *sk) { return OPENSSL_sk_is_sorted((const
OPENSSL_STACK *)sk); } static __attribute__((unused)) inline
struct stack_st_OSSL_PROVIDER * sk_OSSL_PROVIDER_dup(const struct
stack_st_OSSL_PROVIDER *sk) { return (struct stack_st_OSSL_PROVIDER
*)OPENSSL_sk_dup((const OPENSSL_STACK *)sk); } static __attribute__
((unused)) inline struct stack_st_OSSL_PROVIDER *sk_OSSL_PROVIDER_deep_copy
(const struct stack_st_OSSL_PROVIDER *sk, sk_OSSL_PROVIDER_copyfunc
copyfunc, sk_OSSL_PROVIDER_freefunc freefunc) { return (struct
stack_st_OSSL_PROVIDER *)OPENSSL_sk_deep_copy((const OPENSSL_STACK
*)sk, (OPENSSL_sk_copyfunc)copyfunc, (OPENSSL_sk_freefunc)freefunc
); } static __attribute__((unused)) inline sk_OSSL_PROVIDER_compfunc
sk_OSSL_PROVIDER_set_cmp_func(struct stack_st_OSSL_PROVIDER *
sk, sk_OSSL_PROVIDER_compfunc compare) { return (sk_OSSL_PROVIDER_compfunc
)OPENSSL_sk_set_cmp_func((OPENSSL_STACK *)sk, (OPENSSL_sk_compfunc
)compare); }
20
21/*
22 * See comments in opt_verify for explanation of this.
23 */
24enum prov_range { OPT_PROV_ENUMOPT_PROV__FIRST=1600, OPT_PROV_PROVIDER, OPT_PROV_PROVIDER_PATH
, OPT_PROV_PROPQUERY, OPT_PROV__LAST
};
25
26static STACK_OF(OSSL_PROVIDER)struct stack_st_OSSL_PROVIDER *app_providers = NULL((void*)0);
27
28static void provider_free(OSSL_PROVIDER *prov)
29{
30 OSSL_PROVIDER_unload(prov);
31}
32
33int app_provider_load(OSSL_LIB_CTX *libctx, const char *provider_name)
34{
35 OSSL_PROVIDER *prov;
36
37 prov = OSSL_PROVIDER_load(libctx, provider_name);
38 if (prov == NULL((void*)0)) {
39 opt_printf_stderr("%s: unable to load provider %s\n"
40 "Hint: use -provider-path option or OPENSSL_MODULES environment variable.\n",
41 opt_getprog(), provider_name);
42 ERR_print_errors(bio_err);
43 return 0;
44 }
45 if (app_providers == NULL((void*)0))
46 app_providers = sk_OSSL_PROVIDER_new_null();
47 if (app_providers == NULL((void*)0)
48 || !sk_OSSL_PROVIDER_push(app_providers, prov)) {
49 app_providers_cleanup();
50 return 0;
51 }
52 return 1;
53}
54
55void app_providers_cleanup(void)
56{
57 sk_OSSL_PROVIDER_pop_free(app_providers, provider_free);
58 app_providers = NULL((void*)0);
59}
60
61static int opt_provider_path(const char *path)
62{
63 if (path != NULL((void*)0) && *path == '\0')
64 path = NULL((void*)0);
65 return OSSL_PROVIDER_set_default_search_path(app_get0_libctx(), path);
66}
67
68int opt_provider(int opt)
69{
70 const int given = provider_option_given;
Value stored to 'given' during its initialization is never read
71
72 provider_option_given = 1;
73 switch ((enum prov_range)opt) {
74 case OPT_PROV__FIRST:
75 case OPT_PROV__LAST:
76 return 1;
77 case OPT_PROV_PROVIDER:
78 return app_provider_load(app_get0_libctx(), opt_arg());
79 case OPT_PROV_PROVIDER_PATH:
80 return opt_provider_path(opt_arg());
81 case OPT_PROV_PROPQUERY:
82 return app_set_propq(opt_arg());
83 }
84 /* Should never get here but if we do, undo what we did earlier */
85 provider_option_given = given;
86 return 0;
87}
88
89int opt_provider_option_given(void)
90{
91 return provider_option_given;
92}