From be86494186a055e4b5ac15b4c6fb044e89b9a3f7 Mon Sep 17 00:00:00 2001
From: Quanah Gibson-Mount <quanah@openldap.org>
Date: Wed, 22 Dec 2010 00:16:03 +0000
Subject: [PATCH] ITS#6723

---
 CHANGES                    | 4 ++++
 libraries/libldap/dntest.c | 9 +++------
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/CHANGES b/CHANGES
index a8abd1d7e6..ff1df0ead7 100644
--- a/CHANGES
+++ b/CHANGES
@@ -5,6 +5,7 @@ OpenLDAP 2.4.24 Engineering
 	Added slapd-sql autocommit support (ITS#6612)
 	Fixed liblber to not close invalid sockets (ITS#6585)
 	Fixed libldap dnssrv port format specifier (ITS#6644)
+	Fixed libldap EOF handling (ITS#6723)
 	Fixed libldap GnuTLS hang on socket close (ITS#6673)
 	Fixed libldap sasl partial write handling (ITS#6639)
 	Fixed libldap referral chasing (ITS#6602)
@@ -34,6 +35,9 @@ OpenLDAP 2.4.24 Engineering
 	Fixed contrib/autogroup LDAP URI with attribute filter (ITS#6536)
 	Fixed contrib/nssov to only close socket on shutdown (ITS#6676)
 	Fixed contrib/nssov multi platform support (ITS#6604)
+	Build Environment
+		Fixed slapd-tester EOF handling (ITS#6723)
+		Fixed slapd-tesster filter initialization (ITS#6735)
 	Documentation
 		admin24 guide typo fixes (ITS#6609)
 		ldap_open(3) document ldap_set_urllist_proc (ITS#6601)
diff --git a/libraries/libldap/dntest.c b/libraries/libldap/dntest.c
index 0ee80283b0..82e97cc608 100644
--- a/libraries/libldap/dntest.c
+++ b/libraries/libldap/dntest.c
@@ -81,11 +81,9 @@ main( int argc, char *argv[] )
 	}
 
 	if ( strcmp( argv[ 1 ], "-" ) == 0 ) {
-		size_t len;
-		
-		fgets( buf, sizeof( buf ), stdin );
-		len = strlen( buf );
-		if ( len > 0 && buf[ --len ] == '\n' ) {
+		size_t len = fgets( buf, sizeof( buf ), stdin ) ? strlen( buf ) : 0;
+
+		if ( len == 0 || buf[ --len ] == '\n' ) {
 			buf[ len ] = '\0';
 		}
 		strin = buf;
@@ -296,4 +294,3 @@ main( int argc, char *argv[] )
 
 	return( 0 );
 }
-
-- 
GitLab