diff options
author | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2018-05-05 23:15:06 +0200 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2018-05-09 21:44:33 +0200 |
commit | 0653c1561168ca43445bf027a3e57827890c06d0 (patch) | |
tree | c0e14aecbc2fb4660fd91d9ec23df834532c9f22 /lib | |
parent | cbfd03f6fc7820cb721615f44b1955e4d0b667c9 (diff) | |
download | gnutls-0653c1561168ca43445bf027a3e57827890c06d0.tar.gz |
several updates to address issues found by clang static analyzer
Signed-off-by: Nikos Mavrogiannopoulos <nmav@gnutls.org>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/cipher_int.c | 2 | ||||
-rw-r--r-- | lib/constate.c | 4 | ||||
-rw-r--r-- | lib/record.c | 2 | ||||
-rw-r--r-- | lib/tpm.c | 2 | ||||
-rw-r--r-- | lib/x509/crq.c | 2 | ||||
-rw-r--r-- | lib/x509/privkey_pkcs8.c | 14 |
6 files changed, 16 insertions, 10 deletions
diff --git a/lib/cipher_int.c b/lib/cipher_int.c index 786797ca40..1a72ee36fe 100644 --- a/lib/cipher_int.c +++ b/lib/cipher_int.c @@ -276,6 +276,8 @@ int _gnutls_auth_cipher_encrypt2_tag(auth_cipher_hd_st * handle, _gnutls_cipher_get_block_size(handle->cipher.e); unsigned l; + assert(ciphertext != NULL); + if (handle->is_mac) { /* cipher + mac */ if (handle->non_null == 0) { /* NULL cipher + MAC */ MAC(handle, text, textlen); diff --git a/lib/constate.c b/lib/constate.c index 62a1239718..cc8b817715 100644 --- a/lib/constate.c +++ b/lib/constate.c @@ -191,7 +191,7 @@ _tls13_update_keys(gnutls_session_t session, hs_stage_t stage, uint8_t iv_block[MAX_CIPHER_IV_SIZE]; char buf[65]; record_state_st *upd_state; - record_parameters_st *prev; + record_parameters_st *prev = NULL; int ret; /* generate new keys for direction needed and copy old from previous epoch */ @@ -202,6 +202,7 @@ _tls13_update_keys(gnutls_session_t session, hs_stage_t stage, ret = _gnutls_epoch_get(session, EPOCH_READ_CURRENT, &prev); if (ret < 0) return gnutls_assert_val(ret); + assert(prev != NULL); params->read.sequence_number = prev->read.sequence_number; @@ -226,6 +227,7 @@ _tls13_update_keys(gnutls_session_t session, hs_stage_t stage, ret = _gnutls_epoch_get(session, EPOCH_WRITE_CURRENT, &prev); if (ret < 0) return gnutls_assert_val(ret); + assert(prev != NULL); params->write.sequence_number = prev->write.sequence_number; diff --git a/lib/record.c b/lib/record.c index e0c6d3679f..be5f867141 100644 --- a/lib/record.c +++ b/lib/record.c @@ -1573,6 +1573,8 @@ void gnutls_packet_get(gnutls_packet_t packet, gnutls_datum_t *data, unsigned ch } } + assert(packet != NULL); + if (sequence) { memcpy(sequence, packet->record_sequence.i, 8); } @@ -1604,7 +1604,7 @@ gnutls_tpm_privkey_generate(gnutls_pk_algorithm_t pk, unsigned int bits, /* read the public key */ if (pubkey != NULL) { - size_t psize; + size_t psize = 0; ret = gnutls_pubkey_init(&pub); if (ret < 0) { diff --git a/lib/x509/crq.c b/lib/x509/crq.c index 417d630405..fbaed33dd0 100644 --- a/lib/x509/crq.c +++ b/lib/x509/crq.c @@ -2858,7 +2858,7 @@ int gnutls_x509_crq_get_tlsfeatures(gnutls_x509_crq_t crq, unsigned int *critical) { int ret; - gnutls_datum_t der; + gnutls_datum_t der = {NULL, 0}; if (crq == NULL) { gnutls_assert(); diff --git a/lib/x509/privkey_pkcs8.c b/lib/x509/privkey_pkcs8.c index 0070288c58..7e58099e45 100644 --- a/lib/x509/privkey_pkcs8.c +++ b/lib/x509/privkey_pkcs8.c @@ -414,7 +414,7 @@ gnutls_x509_privkey_export_pkcs8(gnutls_x509_privkey_t key, { ASN1_TYPE pkcs8_asn = NULL, pkey_info; int ret; - gnutls_datum_t tmp; + gnutls_datum_t tmp = {NULL, 0}; schema_id schema; if (key == NULL) { @@ -616,7 +616,7 @@ gnutls_x509_privkey_export2_pkcs8(gnutls_x509_privkey_t key, { ASN1_TYPE pkcs8_asn = NULL, pkey_info; int ret; - gnutls_datum_t tmp; + gnutls_datum_t tmp = {NULL, 0}; schema_id schema; if (key == NULL) { @@ -694,7 +694,7 @@ static int pkcs8_key_decrypt(const gnutls_datum_t * raw_key, { int result, len; char enc_oid[MAX_OID_SIZE]; - gnutls_datum_t tmp; + gnutls_datum_t tmp = {NULL, 0}; int params_start, params_end, params_len; struct pbkdf2_params kdf_params; struct pbe_enc_params enc_params; @@ -946,7 +946,7 @@ static int _decode_pkcs8_rsa_key(ASN1_TYPE pkcs8_asn, gnutls_x509_privkey_t pkey) { int ret; - gnutls_datum_t tmp; + gnutls_datum_t tmp = {NULL, 0}; ret = _gnutls_x509_read_value(pkcs8_asn, "privateKey", &tmp); if (ret < 0) { @@ -975,7 +975,7 @@ static int _decode_pkcs8_rsa_pss_key(ASN1_TYPE pkcs8_asn, gnutls_x509_privkey_t pkey) { int ret; - gnutls_datum_t tmp; + gnutls_datum_t tmp = {NULL, 0}; gnutls_x509_spki_st params; memset(¶ms, 0, sizeof(params)); @@ -1020,7 +1020,7 @@ static int _decode_pkcs8_ecc_key(ASN1_TYPE pkcs8_asn, gnutls_x509_privkey_t pkey) { int ret; - gnutls_datum_t tmp; + gnutls_datum_t tmp = {NULL, 0}; unsigned char oid[MAX_OID_SIZE]; unsigned curve = GNUTLS_ECC_CURVE_INVALID; int len, result; @@ -1107,7 +1107,7 @@ static int _decode_pkcs8_dsa_key(ASN1_TYPE pkcs8_asn, gnutls_x509_privkey_t pkey) { int ret; - gnutls_datum_t tmp; + gnutls_datum_t tmp = {NULL, 0}; gnutls_pk_params_init(&pkey->params); |