Browse Source

OpenSSL: Make dh5_init() match the generic implementation

Commit 4104267e81b0a0acdb43f693a67f236b3237a719 ('Fix memory leak on NFC
DH generation error path') modified the generic (non-OpenSSL)
implementation of dh5_init() to free the previously assigned public key,
if any. However, that commit did not modify the OpenSSL specific version
of this function. Add the same change there to maintain consistent
behavior between these two implementations of the same function.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
Jouni Malinen 8 years ago
parent
commit
6a9681e90c
1 changed files with 2 additions and 0 deletions
  1. 2 0
      src/crypto/crypto_openssl.c

+ 2 - 0
src/crypto/crypto_openssl.c

@@ -608,6 +608,7 @@ void * dh5_init(struct wpabuf **priv, struct wpabuf **publ)
 	size_t publen, privlen;
 
 	*priv = NULL;
+	wpabuf_free(*publ);
 	*publ = NULL;
 
 	dh = DH_new();
@@ -653,6 +654,7 @@ err:
 	BIGNUM *p = NULL, *g, *priv_key = NULL, *pub_key = NULL;
 
 	*priv = NULL;
+	wpabuf_free(*publ);
 	*publ = NULL;
 
 	dh = DH_new();