]> git.sur5r.net Git - openldap/commitdiff
ITS#6723: Handle EOF in test programs
authorHallvard Furuseth <hallvard@openldap.org>
Tue, 23 Nov 2010 12:12:54 +0000 (12:12 +0000)
committerHallvard Furuseth <hallvard@openldap.org>
Tue, 23 Nov 2010 12:12:54 +0000 (12:12 +0000)
libraries/libldap/dntest.c
tests/progs/slapd-tester.c

index 0ee80283b09e97ee8219e705ac14232563089abe..82e97cc6084e971cb580dfe2e6dd9c148771fa61 100644 (file)
@@ -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 );
 }
-
index 1e75499568ee1524520b4b2bba0a18b335b7cfc2..5e7e49b7dfdde8bafc111bee0263f3f2a0dc13a5 100644 (file)
@@ -990,7 +990,8 @@ get_search_filters( char *filename, char *filters[], char *attrs[], char *bases[
                        } else {
                                bases[filter] = ArgDup( line );
                        }
-                       fgets( line, BUFSIZ, fp );
+                       if ( fgets( line, BUFSIZ, fp ) == NULL )
+                               *line = '\0';
                        if (( nl = strchr( line, '\r' )) || ( nl = strchr( line, '\n' )))
                                *nl = '\0';