summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/ec/ec_key.c
diff options
context:
space:
mode:
authorjsing <>2015-02-09 15:49:22 +0000
committerjsing <>2015-02-09 15:49:22 +0000
commit16f790d01f7a6fc6c94e2a033a67b80c8ec5291c (patch)
treed924c624d5eb949a9e7e395dc99d92616e911ce9 /src/lib/libcrypto/ec/ec_key.c
parent42f7780549de5b7b5e3e7943cfef87e0e41970fc (diff)
downloadopenbsd-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 '')
-rw-r--r--src/lib/libcrypto/ec/ec_key.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/lib/libcrypto/ec/ec_key.c b/src/lib/libcrypto/ec/ec_key.c
index f9904b4ee9..45192c3231 100644
--- a/src/lib/libcrypto/ec/ec_key.c
+++ b/src/lib/libcrypto/ec/ec_key.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ec_key.c,v 1.10 2015/02/08 22:25:03 miod Exp $ */ 1/* $OpenBSD: ec_key.c,v 1.11 2015/02/09 15:49:22 jsing Exp $ */
2/* 2/*
3 * Written by Nils Larsch for the OpenSSL project. 3 * Written by Nils Larsch for the OpenSSL project.
4 */ 4 */
@@ -359,8 +359,11 @@ EC_KEY_set_public_key_affine_coordinates(EC_KEY * key, BIGNUM * x, BIGNUM * y)
359 if (tmp_nid == NID_X9_62_characteristic_two_field) 359 if (tmp_nid == NID_X9_62_characteristic_two_field)
360 is_char_two = 1; 360 is_char_two = 1;
361 361
362 tx = BN_CTX_get(ctx); 362 if ((tx = BN_CTX_get(ctx)) == NULL)
363 ty = BN_CTX_get(ctx); 363 goto err;
364 if ((ty = BN_CTX_get(ctx)) == NULL)
365 goto err;
366
364#ifndef OPENSSL_NO_EC2M 367#ifndef OPENSSL_NO_EC2M
365 if (is_char_two) { 368 if (is_char_two) {
366 if (!EC_POINT_set_affine_coordinates_GF2m(key->group, point, 369 if (!EC_POINT_set_affine_coordinates_GF2m(key->group, point,