From ac9ccb9ab069ae936798df23ba1f37d42bd1c79c Mon Sep 17 00:00:00 2001 From: Michael Rash Date: Mon, 20 Feb 2017 21:54:22 -0500 Subject: [PATCH] [libfko] check NULL ptr before utilizing - discovered by the PVS-Studio static analyzer --- lib/fko_encryption.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/fko_encryption.c b/lib/fko_encryption.c index 77d27125..e4549224 100644 --- a/lib/fko_encryption.c +++ b/lib/fko_encryption.c @@ -462,11 +462,11 @@ gpg_decrypt(fko_ctx_t ctx, const char *dec_key) if(res != FKO_SUCCESS) /* bail if there was some other problem */ return(res); - pt_len = strnlen(ctx->encoded_msg, MAX_SPA_ENCODED_MSG_SIZE); - if(ctx->encoded_msg == NULL) return(FKO_ERROR_INVALID_DATA_ENCRYPT_DECRYPTED_MESSAGE_MISSING); + pt_len = strnlen(ctx->encoded_msg, MAX_SPA_ENCODED_MSG_SIZE); + if(! is_valid_encoded_msg_len(pt_len)) return(FKO_ERROR_INVALID_DATA_ENCRYPT_DECRYPTED_MSGLEN_VALIDFAIL);