diff options
author | Tim Rühsen <tim.ruehsen@gmx.de> | 2019-02-23 22:21:09 +0000 |
---|---|---|
committer | Tim Rühsen <tim.ruehsen@gmx.de> | 2019-02-23 22:21:09 +0000 |
commit | 115779ad2e3f27f8cc4b5ad9956a22a3921d6edd (patch) | |
tree | 0850345c8f43dbbc9b058cb8bba23038508b6933 /lib/x509 | |
parent | c0af09dee671d90f69e40fdfa5e0117cd995ef18 (diff) | |
parent | 6b5cbc9ea5bdca704bdbe2f8fb551f720d634bc6 (diff) | |
download | gnutls-115779ad2e3f27f8cc4b5ad9956a22a3921d6edd.tar.gz |
Merge branch 'tmp-reset-after-free' into 'master'
Automatically NULLify after gnutls_free()
See merge request gnutls/gnutls!923
Diffstat (limited to 'lib/x509')
-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 | 6 | ||||
-rw-r--r-- | lib/x509/x509_ext.c | 1 |
9 files changed, 4 insertions, 29 deletions
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 ff574ababe..ff7f6a4eb4 100644 --- a/lib/x509/verify-high2.c +++ b/lib/x509/verify-high2.c @@ -184,7 +184,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..995d5cd5cf 100644 --- a/lib/x509/x509.c +++ b/lib/x509/x509.c @@ -227,8 +227,8 @@ int gnutls_x509_crt_init(gnutls_x509_crt_t * cert) if (result < 0) { gnutls_assert(); asn1_delete_structure(&tmp->cert); - gnutls_free(tmp); gnutls_subject_alt_names_deinit(tmp->san); + gnutls_free(tmp); return result; } @@ -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(); |