diff --git a/CHANGES b/CHANGES
index 67cddd999b33952069f7facb7e21f6061d86c8bd..38f72cedac75e6ea053ff03835b7adaf36c430df 100644
--- a/CHANGES
+++ b/CHANGES
@@ -11,6 +11,7 @@ OpenLDAP 2.4.14 Engineering
 	Fixed libldap peer cert memory leak (ITS#5849)
 	Fixed libldap interaction with GnuTLS CN IP-based matches (ITS#5789)
 	Fixed libldap intermediate response behavior (ITS#5896)
+	Fixed libldap IPv6 address handling (ITS#5937)
 	Fixed libldap_r deref building (ITS#5768)
 	Fixed libldap_r slapd lockup when paused during shutdown (ITS#5841)
 	Added slapd syncrepl default retry setting (ITS#5825)
diff --git a/libraries/libldap/tls_g.c b/libraries/libldap/tls_g.c
index a59e33a9acf84799a6a7af396c5727ff31737925..720b399475379da7bf82c6c97f04ec8187c8d201 100644
--- a/libraries/libldap/tls_g.c
+++ b/libraries/libldap/tls_g.c
@@ -575,7 +575,7 @@ tlsg_session_chkhost( LDAP *ld, tls_session *session, const char *name_in )
 #ifdef LDAP_PF_INET6
 	if (name[0] == '[' && strchr(name, ']')) {
 		char *n2 = ldap_strdup(name+1);
-		*strchr(n2, ']') = 2;
+		*strchr(n2, ']') = 0;
 		if (inet_pton(AF_INET6, n2, &addr))
 			ntype = IS_IP6;
 		LDAP_FREE(n2);
diff --git a/libraries/libldap/tls_m.c b/libraries/libldap/tls_m.c
index 9735703054fe30310476a7b2ca4f2bd4698075ec..93ab4ae0c64f63d398f4405066f78adccad16795 100644
--- a/libraries/libldap/tls_m.c
+++ b/libraries/libldap/tls_m.c
@@ -404,7 +404,7 @@ tlsm_session_chkhost( LDAP *ld, tls_session *session, const char *name_in )
 #ifdef LDAP_PF_INET6
 	if (name[0] == '[' && strchr(name, ']')) {
 		char *n2 = ldap_strdup(name+1);
-		*strchr(n2, ']') = 2;
+		*strchr(n2, ']') = 0;
 		if (inet_pton(AF_INET6, n2, &addr))
 			ntype = IS_IP6;
 		LDAP_FREE(n2);
diff --git a/libraries/libldap/tls_o.c b/libraries/libldap/tls_o.c
index fc4f9bc3d6d44113aab80b831b2ae2a53ae28fdb..7936a2db14892d445cb826cb38fd0861c5bb3015 100644
--- a/libraries/libldap/tls_o.c
+++ b/libraries/libldap/tls_o.c
@@ -494,7 +494,7 @@ tlso_session_chkhost( LDAP *ld, tls_session *sess, const char *name_in )
 #ifdef LDAP_PF_INET6
 	if (name[0] == '[' && strchr(name, ']')) {
 		char *n2 = ldap_strdup(name+1);
-		*strchr(n2, ']') = 2;
+		*strchr(n2, ']') = 0;
 		if (inet_pton(AF_INET6, n2, &addr))
 			ntype = IS_IP6;
 		LDAP_FREE(n2);