From: tb Date: Fri, 24 Aug 2018 19:25:31 +0000 (+0000) Subject: In ENGINE_up_ref(), check return value of CRYPTO_add() and report X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=19166cdd9eb4d39c19693cfb1e8d47c7855dc1f3;p=openbsd In ENGINE_up_ref(), check return value of CRYPTO_add() and report failure accordingly. ok jsing --- diff --git a/lib/libcrypto/engine/eng_list.c b/lib/libcrypto/engine/eng_list.c index 8bb1bc58f26..134866d2c69 100644 --- a/lib/libcrypto/engine/eng_list.c +++ b/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; }