[Date Prev][Date Next]
(ITS#4606) Big LDAP Search responses causes IO error in libldap on Windows XP
Full_Name: Alexey Melnikov
OS: Windows XP Professional
Submission from: (NULL) (184.108.40.206)
Problem symptoms: LDAP Search that returns about 20Kb of data is failing in the
middle of decoding with IO error.
Problem description: liblber code is using recv() to read data from socket on
Windows. If there is some data in the TCP buffer already, the function would
complete immediately (without blocking), returning number of bytes
in the buffer. This can lead to a situation when the caller requests,
say 100 bytes, but only gets 32. If the caller needs more data
it would call the recv function again to get more data.
liblber ber_get_next() was setting errno to EAGAIN or EWOULDBLOCK
(depending on which one is defined on the platform) to signal to
the caller that it needs to call ber_get_next again to get more data.
For some bizarre reason when errno is set in liblber, it is not
set when execution returns to libldap. I suspect both DLLs have
private copies of the same errno value.
The end result of errno not being set is that libldap thinks that
there was some socket error and fails the current operation.
The fix is to use WSASetLastError/WSAGetLastError on Windows.
They operate on per thread value and work correctly accross DLL
libldap/liblber were built using /MD flag (to link with "Multithreaded DLL" C
library), using Visual Studio 8 (2005).
I've compares changes to libldap/liblber code between 2.2.27 and trunk of 2.3.X
branch and I think the problem is still there.