From: "cron2 (Code Review)" Date: Sat, 22 Nov 2025 19:06:02 +0000 References: Reply-To: gert@...1296..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net Message-ID: <6a64fb4fafabb18826f224b8274b866c67a0daa0-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="n8ysQIf2Bho="; 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 --n8ysQIf2Bho= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Attention is currently required from: plaisthos. Hello plaisthos, I'd like you to do a code review. Please visit http://gerrit.openvpn.net/c/openvpn/+/1388?usp=3Demail to review the following change. 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. While at it, fix pre-C99 local-variable indent block. 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, 10 insertions(+), 6 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/88/1388/1 diff --git a/src/openvpn/ssl_verify_openssl.c b/src/openvpn/ssl_verify_open= ssl.c index 40d117b..ccbbcc9 100644 --- a/src/openvpn/ssl_verify_openssl.c +++ b/src/openvpn/ssl_verify_openssl.c @@ -202,8 +202,14 @@ 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); + if (x509 =3D=3D NULL) + { + msg(D_TLS_ERRORS, "X509 subject name is NULL"); + return FAILURE; + } + + 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 +250,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 -- 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: newchange Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: I1e9c7eee06bf5f2e8aed8cd2523684539294ac8b Gerrit-Change-Number: 1388 Gerrit-PatchSet: 1 Gerrit-Owner: cron2 Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos --n8ysQIf2Bho= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is cur= rently required from: plaisthos.

cron2 would like plaisthos to review this change.

V= iew Change

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.

While at it, fix pre-C99 local-variable inden= t block.

Reported-By: Joshua Rogers <contact@...2949...>
Fo= und-by: ZeroPath (https://zeropath.com/)

Change-Id: I1e9c7eee06bf5f2= e8aed8cd2523684539294ac8b
Signed-off-by: Gert Doering <gert@...2132...= .>
---
M src/openvpn/ssl_verify_openssl.c
1 file changed, 10 in= sertions(+), 6 deletions(-)

git pull ssh://gerri=
t.openvpn.net:29418/openvpn refs/changes/88/1388/1
diff --git a/src=
/openvpn/ssl_verify_openssl.c b/src/openvpn/ssl_verify_openssl.c
= index 40d117b..ccbbcc9 100644
--- a/src/openvpn/ssl_v= erify_openssl.c
+++ b/src/openvpn/ssl_verify_openssl.c
@@ -202,8 +202,14 @@
X509_NAME_ENTRY *x509= ne =3D NULL;
ASN1_STRING *asn1 =3D NULL;
unsigned char *buf =3D NULL;

- ASN1_OBJECT *field_name_obj =3D OBJ_txt2obj(field_name, = 0);

+ if (x509 =3D=3D NULL)
+ {
+ = msg(D_TLS_ERRORS, "X509 subject name is NULL");
+ return FAILURE;
<= span style=3D"color: hsl(120, 100%, 40%);">+ }
+
+ ASN1_OBJECT *field_name_obj =3D OBJ_txt2obj(field_name, 0);<= /span>
if (field_name_obj =3D=3D NULL)
{=
msg(D_TLS_ERRORS, "Invalid X509 attribute na= me '%s'", field_name);
@@ -244,11 +250,9 @@

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

- {
- const result_t = ret =3D (strlen((char *)buf) < size) ? SUCCESS : FAILURE;
- OPENSSL_free(buf);
- return ret;
<= span style=3D"color: hsl(0, 100%, 40%);">- }

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

To view, visit change 1388<= /a>. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I1e9c7eee06bf5f2e8aed8cd2523= 684539294ac8b
Gerrit-Change-Number: 1388
Gerrit-PatchSet: 1
Gerrit-Owner: cron2 <gert@...1296...>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-Attention: plaisthos <arne-openvpn@...220...= ..1227...>
= --n8ysQIf2Bho=--