From a6249195af27877fbfbc2168dba00a0c1eb6a031 Mon Sep 17 00:00:00 2001 From: Miod Vallat Date: Wed, 9 Jul 2014 13:30:01 +0000 Subject: Simplify error path of DH_check_pub_key() --- lib/libcrypto/dh/dh_check.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'lib') 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; } -- cgit v1.2.3