In ENGINE_up_ref(), check return value of CRYPTO_add() and report
authortb <tb@openbsd.org>
Fri, 24 Aug 2018 19:25:31 +0000 (19:25 +0000)
committertb <tb@openbsd.org>
Fri, 24 Aug 2018 19:25:31 +0000 (19:25 +0000)
failure accordingly.

ok jsing

lib/libcrypto/engine/eng_list.c

index 8bb1bc5..134866d 100644 (file)
@@ -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;
 }