Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
gnutls: removed unused assignments, and use gnutls_calloc()
Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
  • Loading branch information
Nikos Mavrogiannopoulos authored and nmav committed Nov 17, 2020
1 parent 74c0eeb commit 1c23622
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions gnutls.c
Expand Up @@ -583,7 +583,7 @@ static int assign_privkey(struct openconnect_info *vpninfo,
unsigned int nr_certs,
uint8_t *free_certs)
{
gnutls_pcert_st *pcerts = calloc(nr_certs, sizeof(*pcerts));
gnutls_pcert_st *pcerts = gnutls_calloc(nr_certs, sizeof(*pcerts));
int i, err;

if (!pcerts)
Expand Down Expand Up @@ -1092,7 +1092,7 @@ static int load_certificate(struct openconnect_info *vpninfo)
if (!nr_extra_certs)
nr_extra_certs = 1; /* wtf? Oh well, we'll fail later... */

extra_certs = calloc(nr_extra_certs, sizeof(cert));
extra_certs = gnutls_calloc(nr_extra_certs, sizeof(cert));
if (!extra_certs) {
nr_extra_certs = 0;
ret = -ENOMEM;
Expand All @@ -1115,7 +1115,6 @@ static int load_certificate(struct openconnect_info *vpninfo)
goto out;
}
nr_extra_certs = err;
err = 0;

goto got_certs;
got_certs:
Expand Down Expand Up @@ -2667,13 +2666,20 @@ void *establish_eap_ttls(struct openconnect_info *vpninfo)

err = gnutls_priority_set_direct(ttls_sess,
vpninfo->ciphersuite_config, NULL);
if (err < 0) {
vpn_progress(vpninfo, PRG_TRACE,
_("Could not set ciphersuites: %s\n"), vpninfo->ciphersuite_config);
goto fail;
}

err = gnutls_handshake(ttls_sess);
if (!err) {
vpn_progress(vpninfo, PRG_TRACE,
_("Established EAP-TTLS session\n"));
return ttls_sess;
}

fail:
gnutls_deinit(ttls_sess);
return NULL;
}
Expand Down

0 comments on commit 1c23622

Please sign in to comment.