From 849f937d0aaf5911d438c49ccde2b036b62362d5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ond=C5=99ej=20Kuzn=C3=ADk?= <ondra@openldap.org>
Date: Thu, 21 Jun 2018 16:01:43 +0100
Subject: [PATCH 025/109] ITS#8842 Do some printability checks on the dc RDN

---
 libraries/libldap/getdn.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/libraries/libldap/getdn.c b/libraries/libldap/getdn.c
index 16ecd3055..69ff62ac8 100644
--- a/libraries/libldap/getdn.c
+++ b/libraries/libldap/getdn.c
@@ -27,6 +27,7 @@
 
 #include "ldap-int.h"
 #include "ldap_schema.h"
+#include "ldif.h"
 
 /* extension to UFN that turns trailing "dc=value" rdns in DNS style,
  * e.g. "ou=People,dc=openldap,dc=org" => "People, openldap.org" */
@@ -2478,6 +2479,11 @@ dn2domain( LDAPDN dn, struct berval *bv, int pos, int *iRDN )
 			break;
 		}
 
+		if ( ldif_is_not_printable( ava->la_value.bv_val, ava->la_value.bv_len ) ) {
+			domain = 0;
+			break;
+		}
+
 		domain = 1;
 		
 		if ( first ) {
-- 
2.19.1

