]> git.sur5r.net Git - openldap/blobdiff - libraries/liblber/dtest.c
check for overflows
[openldap] / libraries / liblber / dtest.c
index 32ea47713dd93ccd7a94b1fda4118f6722cf468c..6617cf71267744fd5e8849a5b39ce07ad6039489 100644 (file)
@@ -1,11 +1,19 @@
 /* dtest.c - lber decoding test program */
 /* $OpenLDAP$ */
-/*
- * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved.
- * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
+ *
+ * Copyright 1998-2008 The OpenLDAP Foundation.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted only as authorized by the OpenLDAP
+ * Public License.
+ *
+ * A copy of this license is available in the file LICENSE in the
+ * top-level directory of the distribution or, alternatively, at
+ * <http://www.OpenLDAP.org/license.html>.
  */
-/* Portions
- * Copyright (c) 1990 Regents of the University of Michigan.
+/* Portions Copyright (c) 1990 Regents of the University of Michigan.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms are permitted
  * software without specific prior written permission. This software
  * is provided ``as is'' without express or implied warranty.
  */
+/* ACKNOWLEDGEMENTS:
+ * This work was originally developed by the University of Michigan
+ * (as part of U-MICH LDAP).
+ */
 
 #include "portable.h"
 
@@ -76,16 +88,17 @@ main( int argc, char **argv )
 
        for (;;) {
                tag = ber_get_next( sb, &len, ber);
-               if( tag == LBER_ERROR ) {
-                       if( errno == EWOULDBLOCK ) continue;
-                       if( errno == EAGAIN ) continue;
-                       perror( "ber_get_next" );
-                       return( EXIT_FAILURE );
-               }
+               if( tag != LBER_ERROR ) break;
+
+               if( errno == EWOULDBLOCK ) continue;
+               if( errno == EAGAIN ) continue;
+
+               perror( "ber_get_next" );
+               return( EXIT_FAILURE );
        }
 
        printf("decode: message tag 0x%lx and length %ld\n",
-               (unsigned long) tag, (long) len );
+               (unsigned long) tag, (long) len );
 
        for( s = argv[1]; *s; s++ ) {
                char buf[128];