Commit cb9f9f4c authored by GangCao's avatar GangCao Committed by Tomasz Zawadzki
Browse files

sock/posix: free the allocated memory



Related reference:
OPENSSL_hexstr2buf() does the same thing as OPENSSL_hexstr2buf_ex(),
but allocates the space for the result, and returns the result.
It uses a default separator of ':'. The memory is allocated by calling
OPENSSL_malloc() and should be released by calling OPENSSL_free().

Change-Id: I0d2b9b66a41e53f8b438470e59a478c17df2e1e6
Signed-off-by: default avatarGangCao <gang.cao@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15647


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarwanghailiang <hailiangx.e.wang@intel.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@nvidia.com>
Community-CI: Mellanox Build Bot
parent 46ff15a6
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -546,10 +546,12 @@ posix_sock_tls_psk_server_cb(SSL *ssl,
	}
	if (key_len > max_psk_len) {
		SPDK_ERRLOG("Insufficient buffer size to copy PSK\n");
		OPENSSL_free(default_psk);
		goto err;
	}

	memcpy(psk, default_psk, key_len);
	OPENSSL_free(default_psk);

	return key_len;

@@ -585,6 +587,7 @@ posix_sock_tls_psk_client_cb(SSL *ssl, const char *hint,
	}
	if ((strlen(impl_opts->psk_identity) + 1 > max_identity_len)
	    || (key_len > max_psk_len)) {
		OPENSSL_free(default_psk);
		SPDK_ERRLOG("PSK ID or Key buffer is not sufficient\n");
		goto err;
	}
@@ -593,6 +596,7 @@ posix_sock_tls_psk_client_cb(SSL *ssl, const char *hint,

	memcpy(psk, default_psk, key_len);
	SPDK_DEBUGLOG(sock_posix, "Provided out-of-band (OOB) PSK for TLS1.3 client\n");
	OPENSSL_free(default_psk);

	return key_len;