diff options
author | Jonathan Wernberg <jonathaw@axis.com> | 2019-11-28 13:20:44 +0100 |
---|---|---|
committer | James Bottomley <James.Bottomley@HansenPartnership.com> | 2019-12-22 09:11:16 -0800 |
commit | 2b646dcbe51a9d37767e6054d7ce590072473bb5 (patch) | |
tree | bbe46efab45e0ce6af90532175d34761065a618a | |
parent | b263d796a93a2935f1644e36e79e602c528ccfb9 (diff) | |
download | openssl_tpm2_engine-2b646dcbe51a9d37767e6054d7ce590072473bb5.tar.gz |
Fix compile warning on older GCC
GCC cannot, for each possible value of one variable such as "tssl",
keep track of which of all other variables such as "pubkey" and
"privkey" are uninitialized or not. Some GCC versions just assumes
the variable may be uninitialized if it cannot know. Some more recent
GCC versions seem to take the opposite approach.
Either way, a simple refactoring of the error handling eliminates
the uncertainity by making both the if and else clause definitely
set the variables "pubkey" and "privkey" to an initialized value,
so it now compiles fine.
Signed-off-by: Jonathan Wernberg <jonathaw@axis.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
-rw-r--r-- | e_tpm2.c | 30 |
1 files changed, 15 insertions, 15 deletions
@@ -372,27 +372,27 @@ static int tpm2_engine_load_key_core(ENGINE *e, EVP_PKEY **ppkey, } else { BIO_seek(bf, 0); tssl = PEM_read_bio_TSSLOADABLE(bf, NULL, NULL, NULL); - if (tssl) { - /* have error from failed TSSPRIVKEY load */ - ERR_clear_error(); - type = tssl->type; - empty_auth = tssl->emptyAuth; - parent = tssl->parent; - pubkey = tssl->pubkey; - privkey = tssl->privkey; - policy = tssl->policy; + if (!tssl) { + if (!bio) + BIO_free(bf); + if (ppkey) + fprintf(stderr, "Failed to parse file %s\n", key_id); + return 0; } + + /* have error from failed TSSPRIVKEY load */ + ERR_clear_error(); + type = tssl->type; + empty_auth = tssl->emptyAuth; + parent = tssl->parent; + pubkey = tssl->pubkey; + privkey = tssl->privkey; + policy = tssl->policy; } if (!bio) BIO_free(bf); - if (!tssl && !tpk) { - if (ppkey) - fprintf(stderr, "Failed to parse file %s\n", key_id); - return 0; - } - if (!ppkey) { TSSLOADABLE_free(tssl); TSSPRIVKEY_free(tpk); |