Skip to content

Commit 31a02f1

Browse files
committed
Address review comments.
1 parent 4ccd6df commit 31a02f1

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

src/x509.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4860,7 +4860,9 @@ void wolfSSL_GENERAL_NAME_set0_value(WOLFSSL_GENERAL_NAME *a, int type,
48604860

48614861
wolfSSL_GENERAL_NAME_type_free(a);
48624862
a->type = type;
4863-
a->d.dNSName = value;
4863+
if (type == GEN_DNS) {
4864+
a->d.dNSName = value;
4865+
}
48644866
}
48654867

48664868
/* Frees GENERAL_NAME objects.

tests/api.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41889,6 +41889,7 @@ static int test_wolfSSL_GENERAL_NAME_print(void)
4188941889
X509_EXTENSION* ext = NULL;
4189041890
AUTHORITY_INFO_ACCESS* aia = NULL;
4189141891
ACCESS_DESCRIPTION* ad = NULL;
41892+
ASN1_IA5STRING *dnsname = NULL;
4189241893

4189341894
const unsigned char v4Addr[] = {192,168,53,1};
4189441895
const unsigned char v6Addr[] =
@@ -41943,6 +41944,17 @@ static int test_wolfSSL_GENERAL_NAME_print(void)
4194341944
X509_free(x509);
4194441945
x509 = NULL;
4194541946

41947+
/* Lets test for setting as well. */
41948+
ExpectNotNull(gn = GENERAL_NAME_new());
41949+
ExpectNotNull(dnsname = ASN1_IA5STRING_new());
41950+
ExpectIntEQ(ASN1_STRING_set(dnsname, "example.com", -1), 1);
41951+
GENERAL_NAME_set0_value(gn, GEN_DNS, dnsname);
41952+
dnsname = NULL;
41953+
ExpectIntEQ(GENERAL_NAME_print(out, gn), 1);
41954+
XMEMSET(outbuf, 0, sizeof(outbuf));
41955+
ExpectIntGT(BIO_read(out, outbuf, sizeof(outbuf)), 0);
41956+
ExpectIntEQ(XSTRNCMP((const char*)outbuf, dnsStr, XSTRLEN(dnsStr)), 0);
41957+
4194641958
/* test for GEN_URI */
4194741959

4194841960
ExpectTrue((f = XFOPEN("./certs/ocsp/root-ca-cert.pem", "rb")) != XBADFILE);

0 commit comments

Comments
 (0)