]> git.sur5r.net Git - openldap/commitdiff
Fix previous commit
authorLuke Howard <lukeh@openldap.org>
Fri, 10 Feb 2006 15:18:45 +0000 (15:18 +0000)
committerLuke Howard <lukeh@openldap.org>
Fri, 10 Feb 2006 15:18:45 +0000 (15:18 +0000)
clients/tools/ldapexop.c

index e54dbf32e127b843b31eb20defffc83834556407..a972f9745a7a5cc37781821e8150ac02ab580ad0 100644 (file)
@@ -182,36 +182,37 @@ main( int argc, char *argv[] )
                        goto skip;
                }
 
-       } else if ( tool_is_oid( argv[ 0 ] ) ) {
-               struct berval reqdata;
-               struct berval *reqdatap;
+       } else {
                char *p;
 
-               if ( argc > 1 ) {
+               if ( argc != 1 ) {
                        usage();
                }
 
                p = strchr( argv[ 0 ], ':' );
-               if ( p != NULL ) {
+               if ( p != NULL )
                        *p++ = '\0';
 
-                       reqdata.bv_val = p;
-                       reqdata.bv_len = strlen( reqdata.bv_val );
-                       reqdatap = &reqdata;
-               } else
-                       reqdatap = NULL;
+               if ( tool_is_oid( argv[ 0 ] ) ) {
+                       struct berval reqdata;
 
-               tool_server_controls( ld, NULL, 0 );
+                       if ( p ) {
+                               reqdata.bv_val = p;
+                               reqdata.bv_len = strlen( reqdata.bv_val );
+                       }
 
-               rc = ldap_extended_operation( ld, argv[ 0 ], reqdatap, NULL, NULL, &id );
-               if ( rc != LDAP_SUCCESS ) {
-                       tool_perror( "ldap_extended_operation", rc, NULL, NULL, NULL, NULL );
-                       rc = EXIT_FAILURE;
-                       goto skip;
+                       tool_server_controls( ld, NULL, 0 );
+
+                       rc = ldap_extended_operation( ld, argv[ 0 ], p ? &reqdata : NULL, NULL, NULL, &id );
+                       if ( rc != LDAP_SUCCESS ) {
+                               tool_perror( "ldap_extended_operation", rc, NULL, NULL, NULL, NULL );
+                               rc = EXIT_FAILURE;
+                               goto skip;
+                       }
+               } else {
+                       fprintf( stderr, "unknown exop \"%s\"\n\n", argv[ 0 ] );
+                       usage();
                }
-       } else {
-               fprintf( stderr, "unknown exop \"%s\"\n\n", argv[ 0 ] );
-               usage();
        }
 
        for ( ; ; ) {