From fdc94d8250040aa3d148fbaa802e5b9ea78d7c26 Mon Sep 17 00:00:00 2001 From: Jack Lloyd Date: Thu, 7 Sep 2017 13:13:15 -0400 Subject: Fix invalid comparison, potential segfault on invalid type Found by Coverity --- src/lib/ffi/ffi_pkey_algs.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/lib') 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(&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") -- cgit v1.2.3