diff options
author | Tim Rühsen <tim.ruehsen@gmx.de> | 2019-02-12 15:14:07 +0100 |
---|---|---|
committer | Tim Rühsen <tim.ruehsen@gmx.de> | 2019-02-22 13:11:01 +0100 |
commit | 372821c883a3d36ed3ed683844ad9d90818f6392 (patch) | |
tree | 6783b9830f7eb9294a5bd316c9786e5d6981abaf /lib | |
parent | d39778e43d1674cb3ab3685157fd299816d535c0 (diff) | |
download | gnutls-372821c883a3d36ed3ed683844ad9d90818f6392.tar.gz |
Remove redundant resets of variables after free()
Signed-off-by: Tim Rühsen <tim.ruehsen@gmx.de>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/auth.c | 3 | ||||
-rw-r--r-- | lib/auth/rsa.c | 5 | ||||
-rw-r--r-- | lib/auth/rsa_psk.c | 1 | ||||
-rw-r--r-- | lib/auth/srp_sb64.c | 2 | ||||
-rw-r--r-- | lib/cert-cred-x509.c | 3 | ||||
-rw-r--r-- | lib/cert-cred.c | 3 | ||||
-rw-r--r-- | lib/hello_ext.c | 5 | ||||
-rw-r--r-- | lib/mpi.c | 1 | ||||
-rw-r--r-- | lib/nettle/mpi.c | 2 | ||||
-rw-r--r-- | lib/nettle/pk.c | 3 | ||||
-rw-r--r-- | lib/ocsp-api.c | 1 | ||||
-rw-r--r-- | lib/pk.c | 2 | ||||
-rw-r--r-- | lib/pkcs11.c | 1 | ||||
-rw-r--r-- | lib/pkcs11_privkey.c | 6 | ||||
-rw-r--r-- | lib/pkcs11_write.c | 1 | ||||
-rw-r--r-- | lib/session_pack.c | 2 | ||||
-rw-r--r-- | lib/srp.c | 1 | ||||
-rw-r--r-- | lib/str.c | 2 | ||||
-rw-r--r-- | lib/tls13/certificate_request.c | 2 | ||||
-rw-r--r-- | lib/tpm.c | 2 | ||||
-rw-r--r-- | lib/x509/ocsp.c | 15 | ||||
-rw-r--r-- | lib/x509/pkcs12_bag.c | 1 | ||||
-rw-r--r-- | lib/x509/pkcs7-crypt.c | 1 | ||||
-rw-r--r-- | lib/x509/pkcs7.c | 6 | ||||
-rw-r--r-- | lib/x509/privkey_pkcs8.c | 1 | ||||
-rw-r--r-- | lib/x509/verify-high2.c | 1 | ||||
-rw-r--r-- | lib/x509/virt-san.c | 1 | ||||
-rw-r--r-- | lib/x509/x509.c | 4 | ||||
-rw-r--r-- | lib/x509/x509_ext.c | 1 | ||||
-rw-r--r-- | lib/x509_b64.c | 1 |
30 files changed, 9 insertions, 71 deletions
diff --git a/lib/auth.c b/lib/auth.c index dd3fc861fb..4a0e38b444 100644 --- a/lib/auth.c +++ b/lib/auth.c @@ -372,8 +372,6 @@ void _gnutls_free_auth_info(gnutls_session_t session) gnutls_free(info->raw_certificate_list); gnutls_free(info->raw_ocsp_list); - info->raw_certificate_list = NULL; - info->raw_ocsp_list = NULL; info->ncerts = 0; info->nocsp = 0; @@ -390,7 +388,6 @@ void _gnutls_free_auth_info(gnutls_session_t session) } gnutls_free(session->key.auth_info); - session->key.auth_info = NULL; session->key.auth_info_size = 0; session->key.auth_info_type = 0; diff --git a/lib/auth/rsa.c b/lib/auth/rsa.c index d5d0943242..e58b0a1331 100644 --- a/lib/auth/rsa.c +++ b/lib/auth/rsa.c @@ -200,9 +200,8 @@ proc_rsa_client_kx(gnutls_session_t session, uint8_t * data, ret = gnutls_rnd(GNUTLS_RND_NONCE, session->key.key.data, GNUTLS_MASTER_SIZE); if (ret < 0) { - gnutls_free(session->key.key.data); - session->key.key.data = NULL; - session->key.key.size = 0; + gnutls_free(session->key.key.data); + session->key.key.size = 0; gnutls_assert(); return ret; } diff --git a/lib/auth/rsa_psk.c b/lib/auth/rsa_psk.c index 791fcd8bb7..387bfd403e 100644 --- a/lib/auth/rsa_psk.c +++ b/lib/auth/rsa_psk.c @@ -341,7 +341,6 @@ _gnutls_proc_rsa_psk_client_kx(gnutls_session_t session, uint8_t * data, ("auth_rsa_psk: Possible PKCS #1 format attack\n"); if (ret >= 0) { gnutls_free(plaintext.data); - plaintext.data = NULL; } randomize_key = 1; } else { diff --git a/lib/auth/srp_sb64.c b/lib/auth/srp_sb64.c index 1177e76719..7bfffdf070 100644 --- a/lib/auth/srp_sb64.c +++ b/lib/auth/srp_sb64.c @@ -263,7 +263,6 @@ _gnutls_sbase64_decode(char *data, size_t idata_size, uint8_t ** result) tmp = decode(tmpres, datrev); if (tmp < 0) { gnutls_free((*result)); - *result = NULL; return tmp; } @@ -277,7 +276,6 @@ _gnutls_sbase64_decode(char *data, size_t idata_size, uint8_t ** result) tmp = decode(tmpres, (uint8_t *) & data[i]); if (tmp < 0) { gnutls_free((*result)); - *result = NULL; return tmp; } memcpy(&(*result)[j], tmpres, tmp); diff --git a/lib/cert-cred-x509.c b/lib/cert-cred-x509.c index 257f1b989a..925c09b3d5 100644 --- a/lib/cert-cred-x509.c +++ b/lib/cert-cred-x509.c @@ -265,7 +265,6 @@ parse_pem_cert_mem(gnutls_certificate_credentials_t res, gnutls_pcert_import_x509_list(pcerts, unsorted, &ncerts, GNUTLS_X509_CRT_LIST_SORT); if (ret < 0) { gnutls_free(pcerts); - pcerts = NULL; gnutls_assert(); goto cleanup; } @@ -508,7 +507,6 @@ read_cert_url(gnutls_certificate_credentials_t res, gnutls_privkey_t key, const goto cleanup; } gnutls_free(t.data); - t.data = NULL; } ret = _gnutls_certificate_credential_append_keypair(res, key, names, ccert, count); @@ -908,7 +906,6 @@ gnutls_certificate_get_x509_crt(gnutls_certificate_credentials_t res, while (i--) gnutls_x509_crt_deinit((*crt_list)[i]); gnutls_free(*crt_list); - *crt_list = NULL; return gnutls_assert_val(ret); } diff --git a/lib/cert-cred.c b/lib/cert-cred.c index f04ded4c04..35183b7cc7 100644 --- a/lib/cert-cred.c +++ b/lib/cert-cred.c @@ -258,7 +258,6 @@ void gnutls_certificate_free_keys(gnutls_certificate_credentials_t sc) for (j = 0; j < sc->certs[i].ocsp_data_length; j++) { gnutls_free(sc->certs[i].ocsp_data[j].response.data); - sc->certs[i].ocsp_data[j].response.data = NULL; } _gnutls_str_array_clear(&sc->certs[i].names); gnutls_privkey_deinit(sc->certs[i].pkey); @@ -266,8 +265,6 @@ void gnutls_certificate_free_keys(gnutls_certificate_credentials_t sc) gnutls_free(sc->certs); gnutls_free(sc->sorted_cert_idx); - sc->certs = NULL; - sc->sorted_cert_idx = NULL; sc->ncerts = 0; } diff --git a/lib/hello_ext.c b/lib/hello_ext.c index 2d7cd806f6..0a8d4004a3 100644 --- a/lib/hello_ext.c +++ b/lib/hello_ext.c @@ -464,9 +464,8 @@ void _gnutls_hello_ext_deinit(void) continue; if (extfunc[i]->free_struct != 0) { - gnutls_free((void*)extfunc[i]->name); - gnutls_free((void*)extfunc[i]); - extfunc[i] = NULL; + gnutls_free(((hello_ext_entry_st *)extfunc[i])->name); + gnutls_free(extfunc[i]); } } } @@ -88,7 +88,6 @@ _gnutls_mpi_random_modp(bigint_t r, bigint_t p, if (buf_release != 0) { gnutls_free(buf); - buf = NULL; } if (r != NULL) { diff --git a/lib/nettle/mpi.c b/lib/nettle/mpi.c index 8a93ac2786..96bec4aa43 100644 --- a/lib/nettle/mpi.c +++ b/lib/nettle/mpi.c @@ -122,7 +122,6 @@ static int wrap_nettle_mpi_init_multi(bigint_t *w, ...) fail: mpz_clear(TOMPZ(*w)); gnutls_free(*w); - *w = NULL; va_start(args, w); @@ -131,7 +130,6 @@ fail: if (next != last_failed) { mpz_clear(TOMPZ(*next)); gnutls_free(*next); - *next = NULL; } } while(next != last_failed); diff --git a/lib/nettle/pk.c b/lib/nettle/pk.c index 38c098d8d5..5b109ee475 100644 --- a/lib/nettle/pk.c +++ b/lib/nettle/pk.c @@ -371,7 +371,6 @@ dh_cleanup: if (_gnutls_mem_is_zero(out->data, out->size)) { gnutls_free(out->data); - out->data = NULL; gnutls_assert(); ret = GNUTLS_E_RECEIVED_ILLEGAL_PARAMETER; goto cleanup; @@ -2254,8 +2253,6 @@ wrap_nettle_pk_generate_keys(gnutls_pk_algorithm_t algo, params->params_nr = 0; gnutls_free(params->raw_priv.data); gnutls_free(params->raw_pub.data); - params->raw_priv.data = NULL; - params->raw_pub.data = NULL; FAIL_IF_LIB_ERROR; return ret; diff --git a/lib/ocsp-api.c b/lib/ocsp-api.c index d18a1f0c2c..a0005e99d4 100644 --- a/lib/ocsp-api.c +++ b/lib/ocsp-api.c @@ -473,7 +473,6 @@ gnutls_certificate_set_ocsp_status_request_mem(gnutls_certificate_credentials_t nresp++; gnutls_free(der.data); - der.data = NULL; p.data++; p.size--; @@ -537,8 +537,6 @@ void gnutls_pk_params_release(gnutls_pk_params_st * p) } gnutls_free(p->raw_priv.data); gnutls_free(p->raw_pub.data); - p->raw_priv.data = NULL; - p->raw_pub.data = NULL; p->params_nr = 0; } diff --git a/lib/pkcs11.c b/lib/pkcs11.c index 80d7c57b1f..b227c0200e 100644 --- a/lib/pkcs11.c +++ b/lib/pkcs11.c @@ -1236,7 +1236,6 @@ int gnutls_pkcs11_obj_init(gnutls_pkcs11_obj_t * obj) (*obj)->info = p11_kit_uri_new(); if ((*obj)->info == NULL) { gnutls_free(*obj); - *obj = NULL; gnutls_assert(); return GNUTLS_E_MEMORY_ERROR; } diff --git a/lib/pkcs11_privkey.c b/lib/pkcs11_privkey.c index 53a2d8a937..ca45bb60d5 100644 --- a/lib/pkcs11_privkey.c +++ b/lib/pkcs11_privkey.c @@ -443,7 +443,6 @@ _gnutls_pkcs11_privkey_sign(gnutls_pkcs11_privkey_t key, } gnutls_free(tmp.data); - tmp.data = NULL; } else { signature->size = siglen; signature->data = tmp.data; @@ -521,10 +520,8 @@ gnutls_pkcs11_privkey_import_url(gnutls_pkcs11_privkey_t pkey, memset(&pkey->sinfo, 0, sizeof(pkey->sinfo)); - if (pkey->url) { + if (pkey->url) gnutls_free(pkey->url); - pkey->url = NULL; - } if (pkey->uinfo) { p11_kit_uri_free(pkey->uinfo); @@ -621,7 +618,6 @@ gnutls_pkcs11_privkey_import_url(gnutls_pkcs11_privkey_t pkey, pkey->uinfo = NULL; } gnutls_free(pkey->url); - pkey->url = NULL; return ret; } diff --git a/lib/pkcs11_write.c b/lib/pkcs11_write.c index 4a83018fd8..49a47ebf8b 100644 --- a/lib/pkcs11_write.c +++ b/lib/pkcs11_write.c @@ -268,7 +268,6 @@ static void clean_pubkey(struct ck_attribute *a, unsigned a_val) case CKA_EC_PARAMS: case CKA_EC_POINT: gnutls_free(a[i].value); - a[i].value = NULL; break; } } diff --git a/lib/session_pack.c b/lib/session_pack.c index da74f45e0c..3842ed4c4d 100644 --- a/lib/session_pack.c +++ b/lib/session_pack.c @@ -574,8 +574,6 @@ unpack_certificate_auth_info(gnutls_session_t session, gnutls_free(info->raw_certificate_list); gnutls_free(info->raw_ocsp_list); - info->raw_certificate_list = NULL; - info->raw_ocsp_list = NULL; } return ret; @@ -609,7 +609,6 @@ gnutls_srp_set_server_credentials_file(gnutls_srp_server_credentials_t res, if (res->password_conf_file == NULL) { gnutls_assert(); gnutls_free(res->password_file); - res->password_file = NULL; return GNUTLS_E_MEMORY_ERROR; } @@ -80,7 +80,7 @@ void _gnutls_buffer_clear(gnutls_buffer_st * str) return; gnutls_free(str->allocd); - str->data = str->allocd = NULL; + str->data = NULL; str->max_length = 0; str->length = 0; } diff --git a/lib/tls13/certificate_request.c b/lib/tls13/certificate_request.c index 4efeee0377..50602e2338 100644 --- a/lib/tls13/certificate_request.c +++ b/lib/tls13/certificate_request.c @@ -152,7 +152,6 @@ int _gnutls13_recv_certificate_request_int(gnutls_session_t session, gnutls_buff return gnutls_assert_val(ret); gnutls_free(session->internals.post_handshake_cr_context.data); - session->internals.post_handshake_cr_context.data = NULL; ret = _gnutls_set_datum(&session->internals.post_handshake_cr_context, context.data, context.size); if (ret < 0) @@ -279,7 +278,6 @@ int _gnutls13_send_certificate_request(gnutls_session_t session, unsigned again) } gnutls_free(session->internals.post_handshake_cr_context.data); - session->internals.post_handshake_cr_context.data = NULL; ret = _gnutls_set_datum(&session->internals.post_handshake_cr_context, rnd, sizeof(rnd)); if (ret < 0) { @@ -1641,10 +1641,8 @@ gnutls_tpm_privkey_generate(gnutls_pk_algorithm_t pk, unsigned int bits, gnutls_pubkey_deinit(pub); privkey_cleanup: gnutls_free(privkey->data); - privkey->data = NULL; cleanup: gnutls_free(tmpkey.data); - tmpkey.data = NULL; err_sa: pTspi_Context_CloseObject(s.tpm_ctx, key_ctx); err_cc: diff --git a/lib/x509/ocsp.c b/lib/x509/ocsp.c index a52c4aa428..a8edf30ec6 100644 --- a/lib/x509/ocsp.c +++ b/lib/x509/ocsp.c @@ -162,7 +162,6 @@ void gnutls_ocsp_resp_deinit(gnutls_ocsp_resp_t resp) asn1_delete_structure(&resp->basicresp); resp->resp = NULL; - resp->response_type_oid.data = NULL; resp->basicresp = NULL; gnutls_free(resp->der.data); @@ -299,7 +298,6 @@ gnutls_ocsp_resp_import2(gnutls_ocsp_resp_t resp, } gnutls_free(resp->der.data); - resp->der.data = NULL; } resp->init = 1; @@ -1668,18 +1666,12 @@ gnutls_ocsp_resp_get_single(gnutls_ocsp_resp_t resp, return GNUTLS_E_SUCCESS; fail: - if (issuer_name_hash) { + if (issuer_name_hash) gnutls_free(issuer_name_hash->data); - issuer_name_hash->data = NULL; - } - if (issuer_key_hash) { + if (issuer_key_hash) gnutls_free(issuer_key_hash->data); - issuer_key_hash->data = NULL; - } - if (serial_number) { + if (serial_number) gnutls_free(serial_number->data); - serial_number->data = NULL; - } return ret; } @@ -1955,7 +1947,6 @@ gnutls_ocsp_resp_get_certs(gnutls_ocsp_resp_t resp, } gnutls_free(c.data); - c.data = NULL; } tmpcerts[ctr] = NULL; diff --git a/lib/x509/pkcs12_bag.c b/lib/x509/pkcs12_bag.c index 26d2142ea0..35d12ac4b9 100644 --- a/lib/x509/pkcs12_bag.c +++ b/lib/x509/pkcs12_bag.c @@ -62,7 +62,6 @@ static inline void _pkcs12_bag_free_data(gnutls_pkcs12_bag_t bag) _gnutls_free_datum(&bag->element[i].data); _gnutls_free_datum(&bag->element[i].local_key_id); gnutls_free(bag->element[i].friendly_name); - bag->element[i].friendly_name = NULL; bag->element[i].type = 0; } diff --git a/lib/x509/pkcs7-crypt.c b/lib/x509/pkcs7-crypt.c index c2b00e61c1..39eb7784be 100644 --- a/lib/x509/pkcs7-crypt.c +++ b/lib/x509/pkcs7-crypt.c @@ -1269,7 +1269,6 @@ _gnutls_pkcs_raw_decrypt_data(schema_id schema, ASN1_TYPE pkcs8_asn, _gnutls_cipher_init(&ch, ce, &dkey, &d_iv, 0); gnutls_free(key); - key = NULL; if (ret < 0) { gnutls_assert(); diff --git a/lib/x509/pkcs7.c b/lib/x509/pkcs7.c index 37e2cc3a51..bfb464a470 100644 --- a/lib/x509/pkcs7.c +++ b/lib/x509/pkcs7.c @@ -692,7 +692,6 @@ int gnutls_pkcs7_get_signature_info(gnutls_pkcs7_t pkcs7, unsigned idx, ret = gnutls_pkcs7_add_attr(&info->signed_attrs, oid, &tmp, 0); gnutls_free(tmp.data); - tmp.data = NULL; if (ret < 0) { gnutls_assert(); @@ -730,7 +729,6 @@ int gnutls_pkcs7_get_signature_info(gnutls_pkcs7_t pkcs7, unsigned idx, ret = gnutls_pkcs7_add_attr(&info->unsigned_attrs, oid, &tmp, 0); gnutls_free(tmp.data); - tmp.data = NULL; if (ret < 0) { gnutls_assert(); @@ -842,9 +840,7 @@ static int verify_hash_attr(gnutls_pkcs7_t pkcs7, const char *root, } gnutls_free(tmp.data); - tmp.data = NULL; gnutls_free(tmp2.data); - tmp2.data = NULL; } if (msg_digest_ok) @@ -1087,7 +1083,6 @@ static gnutls_x509_crt_t find_verified_issuer_of(gnutls_pkcs7_t pkcs7, gnutls_x509_crt_deinit(issuer); issuer = NULL; gnutls_free(tmp.data); - tmp.data = NULL; continue; } @@ -1204,7 +1199,6 @@ static gnutls_x509_crt_t find_child_of_with_serial(gnutls_pkcs7_t pkcs7, gnutls_x509_crt_deinit(crt); crt = NULL; gnutls_free(tmpdata.data); - tmpdata.data = NULL; continue; } } else { diff --git a/lib/x509/privkey_pkcs8.c b/lib/x509/privkey_pkcs8.c index 049d2fb7ed..d0cb226364 100644 --- a/lib/x509/privkey_pkcs8.c +++ b/lib/x509/privkey_pkcs8.c @@ -601,7 +601,6 @@ gnutls_pkcs8_info(const gnutls_datum_t * data, gnutls_x509_crt_fmt_t format, cleanup: if (ret != GNUTLS_E_UNKNOWN_CIPHER_TYPE && oid) { gnutls_free(*oid); - *oid = NULL; } if (need_free) _gnutls_free_datum(&_data); diff --git a/lib/x509/verify-high2.c b/lib/x509/verify-high2.c index f4a580bb05..07ef8f1fa6 100644 --- a/lib/x509/verify-high2.c +++ b/lib/x509/verify-high2.c @@ -180,7 +180,6 @@ int remove_pkcs11_url(gnutls_x509_trust_list_t list, const char *ca_file) { if (strcmp(ca_file, list->pkcs11_token) == 0) { gnutls_free(list->pkcs11_token); - list->pkcs11_token = NULL; } return 0; } diff --git a/lib/x509/virt-san.c b/lib/x509/virt-san.c index f3b87135b1..a81337e25b 100644 --- a/lib/x509/virt-san.c +++ b/lib/x509/virt-san.c @@ -70,7 +70,6 @@ int _gnutls_alt_name_assign_virt_type(struct name_st *name, unsigned type, gnutl if (ret < 0) return gnutls_assert_val(ret); gnutls_free(san->data); - san->data = NULL; if (othername_oid) { name->othername_oid.data = (uint8_t *) othername_oid; diff --git a/lib/x509/x509.c b/lib/x509/x509.c index 88aab5538e..fa0188ef05 100644 --- a/lib/x509/x509.c +++ b/lib/x509/x509.c @@ -386,7 +386,6 @@ static int cache_alt_names(gnutls_x509_crt_t cert) if (ret >= 0) { ret = gnutls_x509_ext_import_subject_alt_names(&tmpder, cert->san, 0); gnutls_free(tmpder.data); - tmpder.data = NULL; if (ret < 0) return gnutls_assert_val(ret); } @@ -3684,7 +3683,6 @@ gnutls_x509_crt_list_import2(gnutls_x509_crt_t ** certs, if (ret < 0) { gnutls_free(*certs); - *certs = NULL; return ret; } @@ -4316,7 +4314,6 @@ gnutls_x509_crt_list_import_url(gnutls_x509_crt_t **certs, if (gnutls_x509_crt_equals2(crts[i-1], &issuer)) { gnutls_free(issuer.data); - issuer.data = NULL; break; } @@ -4337,7 +4334,6 @@ gnutls_x509_crt_list_import_url(gnutls_x509_crt_t **certs, } gnutls_free(issuer.data); - issuer.data = NULL; } *certs = gnutls_malloc(total*sizeof(gnutls_x509_crt_t)); diff --git a/lib/x509/x509_ext.c b/lib/x509/x509_ext.c index ffc05bc0a3..8a0acd30aa 100644 --- a/lib/x509/x509_ext.c +++ b/lib/x509/x509_ext.c @@ -1994,7 +1994,6 @@ int gnutls_x509_ext_import_policies(const gnutls_datum_t * ext, ret = decode_user_notice(td.data, td.size, &txt); gnutls_free(td.data); - td.data = NULL; if (ret < 0) { gnutls_assert(); diff --git a/lib/x509_b64.c b/lib/x509_b64.c index 9a1037405b..3117843be1 100644 --- a/lib/x509_b64.c +++ b/lib/x509_b64.c @@ -302,7 +302,6 @@ _gnutls_base64_decode(const uint8_t * data, size_t data_size, fail: gnutls_free(result->data); - result->data = NULL; cleanup: gnutls_free(pdata.data); |