diff options
author | 2015-02-09 15:49:22 +0000 | |
---|---|---|
committer | 2015-02-09 15:49:22 +0000 | |
commit | aa389b8c4810b45e7b9b876db8debfbd5206e29e (patch) | |
tree | aceaf6b9cc0050d33c77e910c34260780c91f772 /lib/libssl/src/crypto/rsa/rsa_eay.c | |
parent | Expand the IMPLEMENT_ASN1_FUNCTIONS macro so that the code is visible and (diff) | |
download | wireguard-openbsd-aa389b8c4810b45e7b9b876db8debfbd5206e29e.tar.xz wireguard-openbsd-aa389b8c4810b45e7b9b876db8debfbd5206e29e.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 'lib/libssl/src/crypto/rsa/rsa_eay.c')
-rw-r--r-- | lib/libssl/src/crypto/rsa/rsa_eay.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/libssl/src/crypto/rsa/rsa_eay.c b/lib/libssl/src/crypto/rsa/rsa_eay.c index f8031c87a27..0eb18cf3c79 100644 --- a/lib/libssl/src/crypto/rsa/rsa_eay.c +++ b/lib/libssl/src/crypto/rsa/rsa_eay.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rsa_eay.c,v 1.36 2014/10/18 17:20:40 jsing Exp $ */ +/* $OpenBSD: rsa_eay.c,v 1.37 2015/02/09 15:49:22 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -181,7 +181,7 @@ RSA_eay_public_encrypt(int flen, const unsigned char *from, unsigned char *to, ret = BN_CTX_get(ctx); num = BN_num_bytes(rsa->n); buf = malloc(num); - if (!f || !ret || !buf) { + if (f == NULL || ret == NULL || buf == NULL) { RSAerr(RSA_F_RSA_EAY_PUBLIC_ENCRYPT, ERR_R_MALLOC_FAILURE); goto err; } @@ -366,7 +366,7 @@ RSA_eay_private_encrypt(int flen, const unsigned char *from, unsigned char *to, ret = BN_CTX_get(ctx); num = BN_num_bytes(rsa->n); buf = malloc(num); - if (!f || !ret || !buf) { + if (f == NULL || ret == NULL || buf == NULL) { RSAerr(RSA_F_RSA_EAY_PRIVATE_ENCRYPT, ERR_R_MALLOC_FAILURE); goto err; } |