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

ldap_connect_to_host HP-64 bug (ITS#2459)

Full_Name: Doug Wieland
Version: 2.1.17
OS: HP 64
URL: ftp://ftp.openldap.org/incoming/
Submission from: (NULL) (

ldap_simple_bind_s() fails with "81" when the host parameter for the ldap_init()
call was a numeric IP address rather than a hostname on HP 64bit.

Our analysis:
ldap_connect_to_host() in ../libldap/os-ip.c has a parameter "unsigned long
address", on 64 bit platforms this is 8 bytes.  Later in the function the
following code copies only the first 4 bytes into variable p, which are all
   q = use_hp ? (char *)hp->h_addr_list[i] : (char *)&address;
   AC_MEMCPY(p, q, sizeof(sin.sin_addr) );
This results in an IP address of 0's which can't be resolved resulting in the
error "81".

Our Fix:
Add the local variable to ldap_connect_to_host() t_address and assign address to
it as follows:
#ifdef __LP64__
     unsigned int t_address = address;
     unsigned long t_address = address;

and change the assignment to use t_address:
     q = use_hp ? (char *)hp->h_addr_list[i] : (char *)&t_address;

This has resolved our problems.  Please let me know what your findings are.

Doug Wieland
Senior Research and Development Specialist
Software AG