X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=libraries%2Flibldap%2Fdntest.c;h=25c82809eb93baf280df1ccb58083702584e47ab;hb=fb5ba5f09c604aa2c9cdf7076141da60fbb925b3;hp=9c53ce92166d8925b74554d645e607d82affbd65;hpb=da6d9eb0463255782f3fa70c61fd958d94c048cf;p=openldap diff --git a/libraries/libldap/dntest.c b/libraries/libldap/dntest.c index 9c53ce9216..25c82809eb 100644 --- a/libraries/libldap/dntest.c +++ b/libraries/libldap/dntest.c @@ -2,7 +2,7 @@ /* $OpenLDAP$ */ /* This work is part of OpenLDAP Software . * - * Copyright 1998-2007 The OpenLDAP Foundation. + * Copyright 1998-2011 The OpenLDAP Foundation. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -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 ); } -