summaryrefslogtreecommitdiff
path: root/src/lib/libssl/s3_clnt.c
diff options
context:
space:
mode:
authorjsing <>2014-05-28 13:03:25 +0000
committerjsing <>2014-05-28 13:03:25 +0000
commit1904ce01988b6ea0f5775507b4d812459c5b3f50 (patch)
tree60af46eb8cb0fcb0e51840739e416c98c124d73c /src/lib/libssl/s3_clnt.c
parent60cd1d60f58b32225afb881559d08dbc68a2eb79 (diff)
downloadopenbsd-1904ce01988b6ea0f5775507b4d812459c5b3f50.tar.gz
openbsd-1904ce01988b6ea0f5775507b4d812459c5b3f50.tar.bz2
openbsd-1904ce01988b6ea0f5775507b4d812459c5b3f50.zip
There is no point in checking if a pointer is non-NULL before calling free,
since free already does this for us. Also remove some pointless NULL assignments, where the result from malloc(3) is immediately assigned to the same variable. ok miod@
Diffstat (limited to 'src/lib/libssl/s3_clnt.c')
-rw-r--r--src/lib/libssl/s3_clnt.c27
1 files changed, 9 insertions, 18 deletions
diff --git a/src/lib/libssl/s3_clnt.c b/src/lib/libssl/s3_clnt.c
index 863a05adb3..ffbd83b060 100644
--- a/src/lib/libssl/s3_clnt.c
+++ b/src/lib/libssl/s3_clnt.c
@@ -1292,8 +1292,7 @@ ssl3_get_key_exchange(SSL *s)
1292 */ 1292 */
1293 if (s->s3->tmp.new_cipher->algorithm_mkey & SSL_kPSK) { 1293 if (s->s3->tmp.new_cipher->algorithm_mkey & SSL_kPSK) {
1294 s->session->sess_cert = ssl_sess_cert_new(); 1294 s->session->sess_cert = ssl_sess_cert_new();
1295 if (s->ctx->psk_identity_hint) 1295 free(s->ctx->psk_identity_hint);
1296 free(s->ctx->psk_identity_hint);
1297 s->ctx->psk_identity_hint = NULL; 1296 s->ctx->psk_identity_hint = NULL;
1298 } 1297 }
1299#endif 1298#endif
@@ -1360,8 +1359,7 @@ ssl3_get_key_exchange(SSL *s)
1360 */ 1359 */
1361 memcpy(tmp_id_hint, p, i); 1360 memcpy(tmp_id_hint, p, i);
1362 memset(tmp_id_hint + i, 0, PSK_MAX_IDENTITY_LEN + 1 - i); 1361 memset(tmp_id_hint + i, 0, PSK_MAX_IDENTITY_LEN + 1 - i);
1363 if (s->ctx->psk_identity_hint != NULL) 1362 free(s->ctx->psk_identity_hint);
1364 free(s->ctx->psk_identity_hint);
1365 s->ctx->psk_identity_hint = BUF_strdup(tmp_id_hint); 1363 s->ctx->psk_identity_hint = BUF_strdup(tmp_id_hint);
1366 if (s->ctx->psk_identity_hint == NULL) { 1364 if (s->ctx->psk_identity_hint == NULL) {
1367 SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, 1365 SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE,
@@ -1952,10 +1950,8 @@ ssl3_get_new_session_ticket(SSL *s)
1952 SSL_R_LENGTH_MISMATCH); 1950 SSL_R_LENGTH_MISMATCH);
1953 goto f_err; 1951 goto f_err;
1954 } 1952 }
1955 if (s->session->tlsext_tick) { 1953 free(s->session->tlsext_tick);
1956 free(s->session->tlsext_tick); 1954 s->session->tlsext_ticklen = 0;
1957 s->session->tlsext_ticklen = 0;
1958 }
1959 s->session->tlsext_tick = malloc(ticklen); 1955 s->session->tlsext_tick = malloc(ticklen);
1960 if (!s->session->tlsext_tick) { 1956 if (!s->session->tlsext_tick) {
1961 SSLerr(SSL_F_SSL3_GET_NEW_SESSION_TICKET, 1957 SSLerr(SSL_F_SSL3_GET_NEW_SESSION_TICKET,
@@ -2024,8 +2020,7 @@ ssl3_get_cert_status(SSL *s)
2024 SSL_R_LENGTH_MISMATCH); 2020 SSL_R_LENGTH_MISMATCH);
2025 goto f_err; 2021 goto f_err;
2026 } 2022 }
2027 if (s->tlsext_ocsp_resp) 2023 free(s->tlsext_ocsp_resp);
2028 free(s->tlsext_ocsp_resp);
2029 s->tlsext_ocsp_resp = BUF_memdup(p, resplen); 2024 s->tlsext_ocsp_resp = BUF_memdup(p, resplen);
2030 if (!s->tlsext_ocsp_resp) { 2025 if (!s->tlsext_ocsp_resp) {
2031 al = SSL_AD_INTERNAL_ERROR; 2026 al = SSL_AD_INTERNAL_ERROR;
@@ -2399,8 +2394,7 @@ ssl3_send_client_key_exchange(SSL *s)
2399 2394
2400 /* Free allocated memory */ 2395 /* Free allocated memory */
2401 BN_CTX_free(bn_ctx); 2396 BN_CTX_free(bn_ctx);
2402 if (encodedPoint != NULL) 2397 free(encodedPoint);
2403 free(encodedPoint);
2404 if (clnt_ecdh != NULL) 2398 if (clnt_ecdh != NULL)
2405 EC_KEY_free(clnt_ecdh); 2399 EC_KEY_free(clnt_ecdh);
2406 EVP_PKEY_free(srvr_pub_pkey); 2400 EVP_PKEY_free(srvr_pub_pkey);
@@ -2551,8 +2545,7 @@ ssl3_send_client_key_exchange(SSL *s)
2551 t += psk_len; 2545 t += psk_len;
2552 s2n(psk_len, t); 2546 s2n(psk_len, t);
2553 2547
2554 if (s->session->psk_identity_hint != NULL) 2548 free(s->session->psk_identity_hint);
2555 free(s->session->psk_identity_hint);
2556 s->session->psk_identity_hint = 2549 s->session->psk_identity_hint =
2557 BUF_strdup(s->ctx->psk_identity_hint); 2550 BUF_strdup(s->ctx->psk_identity_hint);
2558 if (s->ctx->psk_identity_hint != NULL && 2551 if (s->ctx->psk_identity_hint != NULL &&
@@ -2562,8 +2555,7 @@ ssl3_send_client_key_exchange(SSL *s)
2562 goto psk_err; 2555 goto psk_err;
2563 } 2556 }
2564 2557
2565 if (s->session->psk_identity != NULL) 2558 free(s->session->psk_identity);
2566 free(s->session->psk_identity);
2567 s->session->psk_identity = BUF_strdup(identity); 2559 s->session->psk_identity = BUF_strdup(identity);
2568 if (s->session->psk_identity == NULL) { 2560 if (s->session->psk_identity == NULL) {
2569 SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, 2561 SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE,
@@ -2613,8 +2605,7 @@ ssl3_send_client_key_exchange(SSL *s)
2613 err: 2605 err:
2614#ifndef OPENSSL_NO_ECDH 2606#ifndef OPENSSL_NO_ECDH
2615 BN_CTX_free(bn_ctx); 2607 BN_CTX_free(bn_ctx);
2616 if (encodedPoint != NULL) 2608 free(encodedPoint);
2617 free(encodedPoint);
2618 if (clnt_ecdh != NULL) 2609 if (clnt_ecdh != NULL)
2619 EC_KEY_free(clnt_ecdh); 2610 EC_KEY_free(clnt_ecdh);
2620 EVP_PKEY_free(srvr_pub_pkey); 2611 EVP_PKEY_free(srvr_pub_pkey);