Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'bug721570' of gitlab.com:floppym/openconnect
  • Loading branch information
dwmw2 committed May 14, 2020
2 parents 3b8d1cd + eef4c1f commit acb4d91
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions gnutls.c
Expand Up @@ -546,12 +546,19 @@ static int count_x509_certificates(gnutls_datum_t *datum)

static int get_cert_name(gnutls_x509_crt_t cert, char *name, size_t namelen)
{
/* When the name buffer is not big enough, gnutls_x509_crt_get_dn*() will
* update the length argument to the required size, and return
* GNUTLS_E_SHORT_MEMORY_BUFFER. We need to avoid clobbering the original
* length variable. */
size_t nl = namelen;
if (gnutls_x509_crt_get_dn_by_oid(cert, GNUTLS_OID_X520_COMMON_NAME,
0, 0, name, &namelen) &&
gnutls_x509_crt_get_dn(cert, name, &namelen)) {
name[namelen-1] = 0;
snprintf(name, namelen-1, "<unknown>");
return -EINVAL;
0, 0, name, &nl)) {
nl = namelen;
if (gnutls_x509_crt_get_dn(cert, name, &nl)) {
name[namelen-1] = 0;
snprintf(name, namelen-1, "<unknown>");
return -EINVAL;
}
}
return 0;
}
Expand Down

0 comments on commit acb4d91

Please sign in to comment.