From d637ef2f260dd49fbfd2057e923eca6948d52293 Mon Sep 17 00:00:00 2001 From: "Emilio A. Escobar" Date: Sat, 2 Dec 2023 18:09:37 -0800 Subject: [PATCH] Fixing typos and more error checks --- src/m_server.c | 2 +- src/s_bsd.c | 10 ++++++---- src/ssl.c | 13 +++++++++++++ 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/m_server.c b/src/m_server.c index 9c33eb37..b6840d7a 100644 --- a/src/m_server.c +++ b/src/m_server.c @@ -187,7 +187,7 @@ do_server_estab(aClient *cptr) sendto_gnotice("from %s: Link with %s established, states:%s%s%s%s", me.name, inpath, ZipOut(cptr) ? " Output-compressed" : "", #ifdef USE_SSL - IsSSL(cptr) ? " encrypted" : "", + (IsSSL(cptr) || RC4EncLink(cptr))? " encrypted" : "", #else RC4EncLink(cptr) ? " encrypted" : "", #endif diff --git a/src/s_bsd.c b/src/s_bsd.c index 07882d09..a25ea8e8 100644 --- a/src/s_bsd.c +++ b/src/s_bsd.c @@ -121,6 +121,10 @@ static char readbuf[8192]; #endif #endif +#ifdef USE_SSL +extern int mydata_index; +#endif + /* * add_local_domain() * Add the domain to hostname, if it is missing @@ -901,7 +905,7 @@ int completed_connection(aClient * cptr) " NICKIP NICKIPSTR TSMODE"); else { - sendto_one(cptr, "CAPAB SSJOIN NOQUIT BURTS UNCONNECT DKEY" + sendto_one(cptr, "CAPAB SSJOIN NOQUIT BURST UNCONNECT DKEY" " ZIP NICKIP NICKIPSTR TSMODE"); SetWantDKEY(cptr); } @@ -1986,11 +1990,9 @@ int connect_server(aConnect *aconn, aClient * by, struct hostent *hp) SetSSL(cptr); SSL_set_fd(cptr->ssl, cptr->fd); - extern int mydata_index; + int ret=0; - - mydata_index = SSL_get_ex_new_index(0, "mydata index", NULL, NULL, NULL); /* * Set the aConn object as SSL data for the verification */ diff --git a/src/ssl.c b/src/ssl.c index af6d0d23..6931e73f 100644 --- a/src/ssl.c +++ b/src/ssl.c @@ -107,6 +107,8 @@ int ssl_init() return 0; } + mydata_index = SSL_get_ex_new_index(0, "aConn data", NULL, NULL, NULL); + return 1; } @@ -474,10 +476,21 @@ int ssl_verify_callback(int preverify_ok, X509_STORE_CTX *ctx) */ X509_NAME *subj = X509_get_subject_name(cert); + + if (!subj) return preverify_ok; + X509_NAME_ENTRY *e = X509_NAME_get_entry(subj, 5); + + if (!e) return preverify_ok; + ASN1_STRING *d = X509_NAME_ENTRY_get_data(e); + + if (!d) return preverify_ok; + char *cn = ASN1_STRING_data(d); + if (!cn) return preverify_ok; + if (!mycmp(cn, conn->name)) { sendto_realops_lev(DEBUG_LEV, "SSL: Valid certificate cn: %s, name: %s", cn, conn->name);