diff options
author | jsing <> | 2015-02-09 15:49:22 +0000 |
---|---|---|
committer | jsing <> | 2015-02-09 15:49:22 +0000 |
commit | 16f790d01f7a6fc6c94e2a033a67b80c8ec5291c (patch) | |
tree | d924c624d5eb949a9e7e395dc99d92616e911ce9 /src/lib/libcrypto/ecdh | |
parent | 42f7780549de5b7b5e3e7943cfef87e0e41970fc (diff) | |
download | openbsd-16f790d01f7a6fc6c94e2a033a67b80c8ec5291c.tar.gz openbsd-16f790d01f7a6fc6c94e2a033a67b80c8ec5291c.tar.bz2 openbsd-16f790d01f7a6fc6c94e2a033a67b80c8ec5291c.zip |
BN_CTX_get() can fail - consistently check its return value.
There are currently cases where the return from each call is checked,
the return from only the last call is checked and cases where it is not
checked at all (including code in bn, ec and engine).
Checking the last return value is valid as once the function fails it will
continue to return NULL. However, in order to be consistent check each
call with the same idiom. This makes it easy to verify.
Note there are still a handful of cases that do not follow the idiom -
these will be handled separately.
ok beck@ doug@
Diffstat (limited to 'src/lib/libcrypto/ecdh')
-rw-r--r-- | src/lib/libcrypto/ecdh/ech_ossl.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/lib/libcrypto/ecdh/ech_ossl.c b/src/lib/libcrypto/ecdh/ech_ossl.c index ee130edeee..4fae7cacfd 100644 --- a/src/lib/libcrypto/ecdh/ech_ossl.c +++ b/src/lib/libcrypto/ecdh/ech_ossl.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ech_ossl.c,v 1.8 2014/07/12 16:03:37 miod Exp $ */ | 1 | /* $OpenBSD: ech_ossl.c,v 1.9 2015/02/09 15:49:22 jsing Exp $ */ |
2 | /* ==================================================================== | 2 | /* ==================================================================== |
3 | * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. | 3 | * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. |
4 | * | 4 | * |
@@ -120,8 +120,10 @@ static int ecdh_compute_key(void *out, size_t outlen, const EC_POINT *pub_key, | |||
120 | 120 | ||
121 | if ((ctx = BN_CTX_new()) == NULL) goto err; | 121 | if ((ctx = BN_CTX_new()) == NULL) goto err; |
122 | BN_CTX_start(ctx); | 122 | BN_CTX_start(ctx); |
123 | x = BN_CTX_get(ctx); | 123 | if ((x = BN_CTX_get(ctx)) == NULL) |
124 | y = BN_CTX_get(ctx); | 124 | goto err; |
125 | if ((y = BN_CTX_get(ctx)) == NULL) | ||
126 | goto err; | ||
125 | 127 | ||
126 | priv_key = EC_KEY_get0_private_key(ecdh); | 128 | priv_key = EC_KEY_get0_private_key(ecdh); |
127 | if (priv_key == NULL) | 129 | if (priv_key == NULL) |