From: "cron2 (Code Review)" Date: Thu, 27 Nov 2025 10:24:19 +0000 In-Reply-To: References: Reply-To: gert@...1296..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, antonio@...2726... Message-ID: <04666b9a9077281b5bbe3f88607e2e42323d5d9e-EmailReplacePatchSet-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="ZT4LaqBi4QY="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: extract_x509_field_ssl(): verify that X509_NAME is not NULL. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: plaisthos Cc: openvpn-devel --ZT4LaqBi4QY= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Attention is currently required from: cron2, ordex, plaisthos. Hello ordex, plaisthos, I'd like you to reexamine a change. Please visit http://gerrit.openvpn.net/c/openvpn/+/1388?usp=3Demail to look at the new patch set (#2). The following approvals got outdated and were removed: Code-Review-1 by ordex Change subject: extract_x509_field_ssl(): verify that X509_NAME is not NULL. ...................................................................... extract_x509_field_ssl(): verify that X509_NAME is not NULL. This seems to be unlikely to ever happen, but this check won't harm - as a matter of coding convention, we do not ensure this inside extract_x509_field_ssl(), but in the (single) caller. While at it, fix pre-C99 local-variable indent block, and missing {} block in else/#endif construction. Reported-By: Joshua Rogers Found-by: ZeroPath (https://zeropath.com/) Change-Id: I1e9c7eee06bf5f2e8aed8cd2523684539294ac8b Signed-off-by: Gert Doering --- M src/openvpn/ssl_verify_openssl.c 1 file changed, 14 insertions(+), 7 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/88/1388/2 diff --git a/src/openvpn/ssl_verify_openssl.c b/src/openvpn/ssl_verify_open= ssl.c index 40d117b..6cb04ee 100644 --- a/src/openvpn/ssl_verify_openssl.c +++ b/src/openvpn/ssl_verify_openssl.c @@ -202,8 +202,8 @@ X509_NAME_ENTRY *x509ne =3D NULL; ASN1_STRING *asn1 =3D NULL; unsigned char *buf =3D NULL; - ASN1_OBJECT *field_name_obj =3D OBJ_txt2obj(field_name, 0); + ASN1_OBJECT *field_name_obj =3D OBJ_txt2obj(field_name, 0); if (field_name_obj =3D=3D NULL) { msg(D_TLS_ERRORS, "Invalid X509 attribute name '%s'", field_name); @@ -244,11 +244,9 @@ strncpynt(out, (char *)buf, size); - { - const result_t ret =3D (strlen((char *)buf) < size) ? SUCCESS : FA= ILURE; - OPENSSL_free(buf); - return ret; - } + const result_t ret =3D (strlen((char *)buf) < size) ? SUCCESS : FAILUR= E; + OPENSSL_free(buf); + return ret; } result_t @@ -278,12 +276,21 @@ } else #endif /* ifdef ENABLE_X509ALTUSERNAME */ + { + X509_NAME *x509_subject_name =3D X509_get_subject_name(peer_cert); + if (x509_subject_name =3D=3D NULL) + { + msg(D_TLS_ERRORS, "X509 subject name is NULL"); + return FAILURE; + } + if (FAILURE - =3D=3D extract_x509_field_ssl(X509_get_subject_name(peer_cert)= , x509_username_field, + =3D=3D extract_x509_field_ssl(x509_subject_name, x509_username= _field, common_name, cn_len)) { return FAILURE; } + } return SUCCESS; } -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1388?usp=3Demail To unsubscribe, or for help writing mail filters, visit http://gerrit.openv= pn.net/settings?usp=3Demail Gerrit-MessageType: newpatchset Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: I1e9c7eee06bf5f2e8aed8cd2523684539294ac8b Gerrit-Change-Number: 1388 Gerrit-PatchSet: 2 Gerrit-Owner: cron2 Gerrit-Reviewer: ordex Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos Gerrit-Attention: cron2 Gerrit-Attention: ordex --ZT4LaqBi4QY= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is cur= rently required from: cron2, ordex, plaisthos.

cron2 uploaded patch set #2 to this change.

View Change

The following approvals got outdated and were removed: Code-Review-1 by ordex

extract_x509_field_ssl(): verify th=
at X509_NAME is not NULL.

This seems to be unlikely to ever happen, = but this check won't harm
- as a matter of coding convention, we do = not ensure this inside
extract_x509_field_ssl(), but in the (single) cal= ler.

While at it, fix pre-C99 local-variable indent block, and missi= ng {}
block in else/#endif construction.

Reported-By: Joshua Roge= rs <contact@...2949...>
Found-by: ZeroPath (https://zeropath.com/)=

Change-Id: I1e9c7eee06bf5f2e8aed8cd2523684539294ac8b
Signed-off-= by: Gert Doering <gert@...1296...>
---
M src/openvpn/ssl_verify= _openssl.c
1 file changed, 14 insertions(+), 7 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes=
/88/1388/2
diff --git a/src/openvpn/ssl_verify_openssl.c b/src/open=
vpn/ssl_verify_openssl.c
index 40d117b..6cb04ee 100644
--- a/src/openvpn/ssl_verify_openssl.c
+++ b/sr= c/openvpn/ssl_verify_openssl.c
@@ -202,8 +202,8 @@ X509_NAME_ENTRY *x509ne =3D NULL;
ASN1_ST= RING *asn1 =3D NULL;
unsigned char *buf =3D NULL;
- ASN1_OBJECT *field_nam= e_obj =3D OBJ_txt2obj(field_name, 0);

+ ASN1_OBJECT *field_name_obj =3D OBJ= _txt2obj(field_name, 0);
if (field_name_obj =3D=3D NUL= L)
{
msg(D_TLS_ERRORS, "= Invalid X509 attribute name '%s'", field_name);
@@ -244,11 +244,9 @@


strncpynt(out= , (char *)buf, size);

- {
- const result_t ret =3D (strlen((char *)buf) < size) ? SUCCESS = : FAILURE;
- OPE= NSSL_free(buf);
- = return ret;
- }
+ const result_t ret= =3D (strlen((char *)buf) < size) ? SUCCESS : FAILURE;
+ OPENSSL_free(buf);
+ return ret;

}=

result_t
@@ -278,12 +27= 6,21 @@
}
else
#= endif /* ifdef ENABLE_X509ALTUSERNAME */
+ {
+ X509_NAME *x509_subject_name =3D X509_get_subject_name(peer_= cert);
+ if (x= 509_subject_name =3D=3D NULL)
+ {
+= msg(D_TLS_ERRORS, "X509 subject name is NULL");
+ return FAILUR= E;
+ }<= br>+
i= f (FAILURE
- = =3D=3D extract_x509_field_ssl(X509_get_subject_name(peer_cert), x509_usern= ame_field,
+ = =3D=3D extract_x509_field_ssl(x509_subject_name, x509_username_field,
common_name, cn_len))<= /span>
{
return FAILURE;
}
+ }

return SUCCESS;
= }

To view, visit change 1388. To uns= ubscribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I1e9c7eee06bf5f2e8aed8cd2523= 684539294ac8b
Gerrit-Change-Number: 1388
Gerrit-PatchSet: 2
Gerrit-Owner: cron2 <gert@...1296...>
Gerrit-Reviewer: ordex <antonio@...2726...&= gt;
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-Attention: plaisthos <arne-openvpn@...220...= ..1227...>
Gerrit-Attention: cron2 <gert@...1296...>= ;
Gerrit-Attention: ordex <antonio@...2726...= >
= --ZT4LaqBi4QY=--