summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormiod <miod@openbsd.org>2014-07-09 13:30:00 +0000
committermiod <miod@openbsd.org>2014-07-09 13:30:00 +0000
commit82d7f4278a2f03ecf05c6f9d21e12499f48b95c0 (patch)
tree86de2f7a6b3e939f76dff274bcb5c3de1e6a2a07
parentKNF (diff)
downloadwireguard-openbsd-82d7f4278a2f03ecf05c6f9d21e12499f48b95c0.tar.xz
wireguard-openbsd-82d7f4278a2f03ecf05c6f9d21e12499f48b95c0.zip
Simplify error path of DH_check_pub_key()
-rw-r--r--lib/libcrypto/dh/dh_check.c12
-rw-r--r--lib/libssl/src/crypto/dh/dh_check.c12
2 files changed, 8 insertions, 16 deletions
diff --git a/lib/libcrypto/dh/dh_check.c b/lib/libcrypto/dh/dh_check.c
index 1df8f4cdc76..070a33081a7 100644
--- a/lib/libcrypto/dh/dh_check.c
+++ b/lib/libcrypto/dh/dh_check.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dh_check.c,v 1.11 2014/07/09 13:26:47 miod Exp $ */
+/* $OpenBSD: dh_check.c,v 1.12 2014/07/09 13:30:00 miod Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
@@ -124,13 +124,12 @@ err:
int
DH_check_pub_key(const DH *dh, const BIGNUM *pub_key, int *ret)
{
- int ok = 0;
BIGNUM *q = NULL;
*ret = 0;
q = BN_new();
if (q == NULL)
- goto err;
+ return 0;
BN_set_word(q, 1);
if (BN_cmp(pub_key, q) <= 0)
*ret |= DH_CHECK_PUBKEY_TOO_SMALL;
@@ -139,9 +138,6 @@ DH_check_pub_key(const DH *dh, const BIGNUM *pub_key, int *ret)
if (BN_cmp(pub_key, q) >= 0)
*ret |= DH_CHECK_PUBKEY_TOO_LARGE;
- ok = 1;
-err:
- if (q != NULL)
- BN_free(q);
- return ok;
+ BN_free(q);
+ return 1;
}
diff --git a/lib/libssl/src/crypto/dh/dh_check.c b/lib/libssl/src/crypto/dh/dh_check.c
index 1df8f4cdc76..070a33081a7 100644
--- a/lib/libssl/src/crypto/dh/dh_check.c
+++ b/lib/libssl/src/crypto/dh/dh_check.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dh_check.c,v 1.11 2014/07/09 13:26:47 miod Exp $ */
+/* $OpenBSD: dh_check.c,v 1.12 2014/07/09 13:30:00 miod Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
@@ -124,13 +124,12 @@ err:
int
DH_check_pub_key(const DH *dh, const BIGNUM *pub_key, int *ret)
{
- int ok = 0;
BIGNUM *q = NULL;
*ret = 0;
q = BN_new();
if (q == NULL)
- goto err;
+ return 0;
BN_set_word(q, 1);
if (BN_cmp(pub_key, q) <= 0)
*ret |= DH_CHECK_PUBKEY_TOO_SMALL;
@@ -139,9 +138,6 @@ DH_check_pub_key(const DH *dh, const BIGNUM *pub_key, int *ret)
if (BN_cmp(pub_key, q) >= 0)
*ret |= DH_CHECK_PUBKEY_TOO_LARGE;
- ok = 1;
-err:
- if (q != NULL)
- BN_free(q);
- return ok;
+ BN_free(q);
+ return 1;
}