[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: program segfaults on ldap_get_values/ldap_get_values_len



> I'm trying to access LDAP from a C program (the first time I've used
> the OpenLDAP API) and so far I've only met with moderate success.
>
> I can bind without issue, but I need to retrieve the values held by a
> specific multi valued attribute, and that's where I'm having issues.
>
> I was using ldap_get_values() and all the other deprecated functions, but
> have recently converted my code to only use what's available in 2.4.x
>
> Sadly, that didn't fix the problem, it still happens.
>
> This line:
>
> attr_values = ldap_get_values_len(ldap_conn, entry, attr);
>
> Segfaults with SIGABRT and prints this to stderr:
>
> Assertion failed: (LBER_VALID( ber )), function ber_scanf, file decode.c,
> line 779.
>
> This is OpenLDAP 2.4.8 on FreeBSD 7.0-RELEASE (as built out of PORTS).

It appears that you're passing broken arguments to ldap_get_values*();
however, you don't provide details on what happens before.  My guess is
that entry was not obtained from the appropriate calls to the API.  It
should be the result of calling ldap_first_entry() or ldap_next_entry()
applied to the LDAPMessage pointer resulting from ldap_result() or
ldap_search*_s().  Please look at clients/tools/ldapsearch.c and related
files for a thorough example.

p.



Ing. Pierangelo Masarati
OpenLDAP Core Team

SysNet s.r.l.
via Dossi, 8 - 27100 Pavia - ITALIA
http://www.sys-net.it
---------------------------------------
Office:  +39 02 23998309
Mobile:  +39 333 4963172
Email:   pierangelo.masarati@sys-net.it
---------------------------------------