GCC 12 static analyzer: error: dereference of NULL 'alginfo' in openssleddsa_link.c
GCC 12.2.1 static analyzer (-fanalyzer
) from Fedora 37 claims the following issue in openssleddsa_link.c
.
openssleddsa_link.c: In function 'raw_key_to_ossl':
openssleddsa_link.c:92:13: error: dereference of NULL 'alginfo' [CWE-476] [-Werror=analyzer-null-dereference]
92 | int pkey_type = alginfo->pkey_type;
| ^~~~~~~~~
'check_algorithm': events 1-4
|
| 599 | check_algorithm(unsigned char algorithm) {
| | ^~~~~~~~~~~~~~~
| | |
| | (1) entry to 'check_algorithm'
|......
| 609 | if (evp_md_ctx == NULL) {
| | ~
| | |
| | (2) following 'false' branch (when 'evp_md_ctx' is non-NULL)...
| 610 | DST_RET(ISC_R_NOMEMORY);
| | ~
| | |
| | (3) ...to here
|......
| 629 | alginfo = openssleddsa_alg_info(algorithm);
| | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| | |
| | (4) calling 'openssleddsa_alg_info' from 'check_algorithm'
|
+--> 'openssleddsa_alg_info': events 5-8
|
| 62 | openssleddsa_alg_info(unsigned int key_alg) {
| | ^~~~~~~~~~~~~~~~~~~~~
| | |
| | (5) entry to 'openssleddsa_alg_info'
| 63 | #if HAVE_OPENSSL_ED25519
| 64 | if (key_alg == DST_ALG_ED25519) {
| | ~
| | |
| | (6) following 'false' branch (when 'key_alg != 15')...
|......
| 75 | if (key_alg == DST_ALG_ED448) {
| | ~~ ~
| | | |
| | | (8) following 'false' branch (when 'key_alg != 16')...
| | (7) ...to here
|
'openssleddsa_alg_info': event 9
|
|cc1:
| (9): ...to here
|
<------+
|
'check_algorithm': events 10-11
|
| 629 | alginfo = openssleddsa_alg_info(algorithm);
| | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| | |
| | (10) return of NULL to 'check_algorithm' from 'openssleddsa_alg_info'
|......
| 636 | ret = raw_key_to_ossl(alginfo, 0, key, &key_len, &pkey);
| | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| | |
| | (11) calling 'raw_key_to_ossl' from 'check_algorithm'
|
+--> 'raw_key_to_ossl': events 12-13
|
| 89 | raw_key_to_ossl(const eddsa_alginfo_t *alginfo, int private,
| | ^~~~~~~~~~~~~~~
| | |
| | (12) entry to 'raw_key_to_ossl'
|......
| 92 | int pkey_type = alginfo->pkey_type;
| | ~~~~~~~~~
| | |
| | (13) dereference of NULL 'alginfo'
|