From: Pierangelo Masarati Date: Sat, 18 Sep 2010 18:24:31 +0000 (+0000) Subject: fix multiple generic control parsing X-Git-Tag: MIGRATION_CVS2GIT~477 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=5524873079aea561584d7bf4bc6e31ccb627bd08;p=openldap fix multiple generic control parsing --- diff --git a/clients/tools/ldapsearch.c b/clients/tools/ldapsearch.c index a851feeb39..65cfd9a67d 100644 --- a/clients/tools/ldapsearch.c +++ b/clients/tools/ldapsearch.c @@ -139,7 +139,7 @@ usage( void ) #ifdef LDAP_CONTROL_X_DEREF fprintf( stderr, _(" [!]deref=derefAttr:attr[,...][;derefAttr:attr[,...][;...]]\n")); #endif - fprintf( stderr, _(" [!]=: (generic control; no response handling)\n")); + fprintf( stderr, _(" [!][=:] (generic control; no response handling)\n")); fprintf( stderr, _(" -f file read operations from `file'\n")); fprintf( stderr, _(" -F prefix URL prefix for files (default: %s)\n"), def_urlpre); fprintf( stderr, _(" -l limit time limit (in seconds, or \"none\" or \"max\") for search\n")); @@ -625,7 +625,7 @@ handle_private_option( int i ) } else if ( tool_is_oid( control ) ) { if ( c != NULL ) { int i; - for ( i = 0; c[ i ].ldctl_oid != NULL; i++ ) { + for ( i = 0; i < nctrls; i++ ) { if ( strcmp( control, c[ i ].ldctl_oid ) == 0 ) { fprintf( stderr, "%s control previously specified\n", control ); exit( EXIT_FAILURE ); @@ -646,18 +646,20 @@ handle_private_option( int i ) c[ nctrls - 1 ].ldctl_value.bv_len = 0; } else if ( cvalue[ 0 ] == ':' ) { - struct berval type; - struct berval value; - int freeval; + struct berval type; + struct berval value; + int freeval; + char save_c; cvalue++; /* dummy type "x" * to use ldif_parse_line2() */ + save_c = cvalue[ -2 ]; cvalue[ -2 ] = 'x'; ldif_parse_line2( &cvalue[ -2 ], &type, &value, &freeval ); - cvalue[ -2 ] = '\0'; + cvalue[ -2 ] = save_c; if ( freeval ) { c[ nctrls - 1 ].ldctl_value = value; @@ -665,6 +667,11 @@ handle_private_option( int i ) } else { ber_dupbv( &c[ nctrls - 1 ].ldctl_value, &value ); } + + } else { + fprintf( stderr, "unable to parse %s control value\n", control ); + exit( EXIT_FAILURE ); + } /* criticality */