From 0f07f24d827710eec2b2d4e7fc87bb37f5bcc8d2 Mon Sep 17 00:00:00 2001 From: tb <> Date: Fri, 24 Aug 2018 19:25:31 +0000 Subject: In ENGINE_up_ref(), check return value of CRYPTO_add() and report failure accordingly. ok jsing --- src/lib/libcrypto/engine/eng_list.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/lib/libcrypto/engine/eng_list.c b/src/lib/libcrypto/engine/eng_list.c index 8bb1bc58f2..134866d2c6 100644 --- a/src/lib/libcrypto/engine/eng_list.c +++ b/src/lib/libcrypto/engine/eng_list.c @@ -1,4 +1,4 @@ -/* $OpenBSD: eng_list.c,v 1.22 2017/01/29 17:49:23 beck Exp $ */ +/* $OpenBSD: eng_list.c,v 1.23 2018/08/24 19:25:31 tb Exp $ */ /* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL * project 2000. */ @@ -373,10 +373,12 @@ ENGINE_by_id(const char *id) int ENGINE_up_ref(ENGINE *e) { + int refs; + if (e == NULL) { ENGINEerror(ERR_R_PASSED_NULL_PARAMETER); return 0; } - CRYPTO_add(&e->struct_ref, 1, CRYPTO_LOCK_ENGINE); - return 1; + refs = CRYPTO_add(&e->struct_ref, 1, CRYPTO_LOCK_ENGINE); + return refs > 1 ? 1 : 0; } -- cgit v1.2.3-55-g6feb