}
-/* OLD U-Mich ber_init() */
void
-ber_init_w_nullc( BerElement *ber, int options )
+ber_init2( BerElement *ber, struct berval *bv, int options )
{
assert( ber != NULL );
- ber_int_options.lbo_valid = LBER_INITIALIZED;
+ ber_int_options.lbo_valid = LBER_INITIALIZED;
(void) memset( (char *)ber, '\0', sizeof( BerElement ));
ber->ber_valid = LBER_VALID_BERELEMENT;
ber->ber_options = (char) options;
ber->ber_debug = ber_int_debug;
+ if ( bv != NULL ) {
+ ber->ber_buf = bv->bv_val;
+ ber->ber_ptr = ber->ber_buf;
+ ber->ber_end = ber->ber_buf + bv->bv_len;
+ }
+
assert( LBER_VALID( ber ) );
}
+/* OLD U-Mich ber_init() */
+void
+ber_init_w_nullc( BerElement *ber, int options )
+{
+ ber_init2( ber, NULL, options );
+}
+
/* New C-API ber_init() */
/* This function constructs a BerElement containing a copy
** of the data in the bv argument.
int rc = LDAP_SUCCESS;
ber_tag_t tag;
ber_len_t len;
- BerElement *ber;
+ char berbuf[256];
+ BerElement *ber = (BerElement *)berbuf;
if( reqdata == NULL ) {
return LDAP_SUCCESS;
}
- ber = ber_init( reqdata );
-
- if( ber == NULL ) {
-#ifdef NEW_LOGGING
- LDAP_LOG(( "operation", LDAP_LEVEL_ERR,
- "slap_passwd_parse: ber_init failed\n" ));
-#else
- Debug( LDAP_DEBUG_TRACE, "slap_passwd_parse: ber_init failed\n",
- 0, 0, 0 );
-#endif
-
- *text = "password decoding error";
- return LDAP_PROTOCOL_ERROR;
- }
+ /* ber_init2 uses reqdata directly, doesn't allocate new buffers */
+ ber_init2( ber, reqdata, 0 );
tag = ber_scanf( ber, "{" /*}*/ );
}
done:
- if( rc != LDAP_SUCCESS ) {
- if( id && id->bv_val != NULL ) {
- free( id->bv_val );
- id->bv_val = NULL;
- }
-
- if( oldpass && oldpass->bv_val != NULL ) {
- free( oldpass->bv_val );
- oldpass->bv_val = NULL;
- }
-
- if( newpass && newpass->bv_val != NULL ) {
- free( newpass->bv_val );
- newpass->bv_val = NULL;
- }
- }
-
- ber_free( ber, 1 );
return rc;
}