/*
+ * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
+/* Portions
* Copyright (c) 1990 Regents of the University of Michigan.
* All rights reserved.
*
#include "portable.h"
-#ifndef lint
-static char copyright[] = "@(#) Copyright (c) 1990 Regents of the University of Michigan.\nAll rights reserved.\n";
-#endif
-
#include <stdio.h>
#include <stdlib.h>
#include "ldap-int.h"
char **
-ldap_get_values( LDAP *ld, LDAPMessage *entry, char *target )
+ldap_get_values( LDAP *ld, LDAPMessage *entry, LDAP_CONST char *target )
{
BerElement ber;
- char attr[LDAP_MAX_ATTR_LEN];
+ char *attr;
int found = 0;
- long len;
char **vals;
Debug( LDAP_DEBUG_TRACE, "ldap_get_values\n", 0, 0, 0 );
ber = *entry->lm_ber;
/* skip sequence, dn, sequence of, and snag the first attr */
- len = sizeof(attr);
- if ( ber_scanf( &ber, "{x{{s", attr, &len ) == LBER_ERROR ) {
+ if ( ber_scanf( &ber, "{x{{a", &attr ) == LBER_ERROR ) {
ld->ld_errno = LDAP_DECODING_ERROR;
return( NULL );
}
/* break out on success, return out on error */
while ( ! found ) {
- len = sizeof(attr);
- if ( ber_scanf( &ber, "x}{s", attr, &len ) == LBER_ERROR ) {
+ free(attr);
+ attr = NULL;
+
+ if ( ber_scanf( &ber, "x}{a", &attr ) == LBER_ERROR ) {
ld->ld_errno = LDAP_DECODING_ERROR;
return( NULL );
}
if ( strcasecmp( target, attr ) == 0 )
break;
+
}
+ free(attr);
+ attr = NULL;
+
/*
* if we get this far, we've found the attribute and are sitting
* just before the set of values.
}
struct berval **
-ldap_get_values_len( LDAP *ld, LDAPMessage *entry, char *target )
+ldap_get_values_len( LDAP *ld, LDAPMessage *entry, LDAP_CONST char *target )
{
BerElement ber;
- char attr[LDAP_MAX_ATTR_LEN];
+ char *attr;
int found = 0;
- long len;
struct berval **vals;
Debug( LDAP_DEBUG_TRACE, "ldap_get_values_len\n", 0, 0, 0 );
ber = *entry->lm_ber;
/* skip sequence, dn, sequence of, and snag the first attr */
- len = sizeof(attr);
- if ( ber_scanf( &ber, "{x{{s", attr, &len ) == LBER_ERROR ) {
+ if ( ber_scanf( &ber, "{x{{a", &attr ) == LBER_ERROR ) {
ld->ld_errno = LDAP_DECODING_ERROR;
return( NULL );
}
/* break out on success, return out on error */
while ( ! found ) {
- len = sizeof(attr);
- if ( ber_scanf( &ber, "x}{s", attr, &len ) == LBER_ERROR ) {
+ free( attr );
+ attr = NULL;
+
+ if ( ber_scanf( &ber, "x}{a", &attr ) == LBER_ERROR ) {
ld->ld_errno = LDAP_DECODING_ERROR;
return( NULL );
}
break;
}
+ free( attr );
+ attr = NULL;
+
/*
* if we get this far, we've found the attribute and are sitting
* just before the set of values.