diff options
author | Jack Lloyd <[email protected]> | 2017-09-07 13:13:15 -0400 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2017-09-07 13:13:15 -0400 |
commit | fdc94d8250040aa3d148fbaa802e5b9ea78d7c26 (patch) | |
tree | 6bc411969ad99400b2844c29b5535a287891c421 /src/lib/ffi | |
parent | acff905dfeb2055f0e78d5b5ea0763896e9577d3 (diff) |
Fix invalid comparison, potential segfault on invalid type
Found by Coverity
Diffstat (limited to 'src/lib/ffi')
-rw-r--r-- | src/lib/ffi/ffi_pkey_algs.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/lib/ffi/ffi_pkey_algs.cpp b/src/lib/ffi/ffi_pkey_algs.cpp index 83ee51768..36f7f25a5 100644 --- a/src/lib/ffi/ffi_pkey_algs.cpp +++ b/src/lib/ffi/ffi_pkey_algs.cpp @@ -586,7 +586,8 @@ int botan_pubkey_sm2_compute_za(uint8_t out[], return ffi_guard_thunk(BOTAN_CURRENT_FUNCTION, [=]() { const Botan::Public_Key& pub_key = safe_get(key); const Botan::EC_PublicKey* ec_key = dynamic_cast<const Botan::EC_PublicKey*>(&pub_key); - if(key == nullptr) + + if(ec_key == nullptr) return BOTAN_FFI_ERROR_BAD_PARAMETER; if(ec_key->algo_name() != "SM2_Sig" && ec_key->algo_name() != "SM2_Enc") |