]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/tools/slapcommon.c
Revert last commit
[openldap] / servers / slapd / tools / slapcommon.c
index 6719743360beafc38c906e966c51f079f126c7a3..73fabc76bb3fd82912155f384a0e2e6291acb2e1 100644 (file)
@@ -1,9 +1,28 @@
+/* slapcommon.c - common routine for the slap tools */
 /* $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-2003 The OpenLDAP Foundation.
+ * Portions Copyright 1998-2003 Kurt D. Zeilenga.
+ * Portions Copyright 2003 IBM Corporation.
+ * 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 file LICENSE in the
+ * top-level directory of the distribution or, alternatively, at
+ * <http://www.OpenLDAP.org/license.html>.
+ */
+/* ACKNOWLEDGEMENTS:
+ * This work was initially developed by Kurt Zeilenga for inclusion
+ * in OpenLDAP Software.  Additional signficant contributors include
+ *    Jong Hyuk Choi
+ *    Hallvard B. Furuseth
+ *    Howard Chu
+ *    Pierangelo Masarati
  */
-/* slapcommon.c - common routine for the slap tools */
 
 #include "portable.h"
 
@@ -151,7 +170,7 @@ slap_tool_init(
 
                case 'i': /* specify syncrepl id list */
                        replica_id_string = strdup( optarg );
-                       if ( !isdigit( *replica_id_string )) {
+                       if ( !isdigit( (unsigned char) *replica_id_string )) {
                                usage( tool );
                                exit( EXIT_FAILURE );
                        }
@@ -160,6 +179,12 @@ slap_tool_init(
                        replica_id_list = ch_calloc( i + 1, sizeof( int ) );
                        for ( i = 0; replica_id_strlist && replica_id_strlist[i]; i++ ) {
                                replica_id_list[i] = atoi( replica_id_strlist[i] );
+                               if ( replica_id_list[i] >= 1000 ) {
+                                       fprintf(stderr,
+                                               "%s: syncrepl id %d is out of range [0..999]\n",
+                                               progname, replica_id_list[i] );
+                                       exit( EXIT_FAILURE );
+                               }
                        }
                        replica_id_list[i] = -1;
                        break;
@@ -387,7 +412,10 @@ slap_tool_init(
        mal_leaktrace(1);
 #endif
 
-       slap_startup( be );
+       if ( slap_startup( be ) ) {
+               fprintf( stderr, "slap_startup failed\n" );
+               exit( EXIT_FAILURE );
+       }
 }
 
 void slap_tool_destroy( void )