Repository navigation
Use the native timeval layout for LDAP timeouts on Unix - #136587
Merged
Merged
Conversation
LDAP_TIMEVAL was declared with two 32-bit ints, which is the Windows LDAP_TIMEVAL (LONG fields). The same struct is passed by reference to OpenLDAP (ldap_set_option(LDAP_OPT_NETWORK_TIMEOUT), ldap_result, ldap_search_ext), which expects a struct timeval of time_t/suseconds_t, i.e. two C longs (16 bytes on LP64). OpenLDAP therefore read 8 bytes past the managed struct and interpreted tv_sec and tv_usec of the managed value together as its 64-bit tv_sec. As a result LdapConnection.Timeout was not honored (a connection attempt to an unreachable host only failed after the OS TCP timeout) and a search time limit was only correct by accident. Declare the fields as CLong, which is a 32-bit LONG on Windows (unchanged layout) and a 64-bit long on LP64 Unix, matching both native definitions with a single type. Co-authored-by: Copilot <[email protected]> Copilot-Session: a13c23e0-b8e7-47bd-9714-cdc27528b527
|
Azure Pipelines: Successfully started running 3 pipeline(s). 13 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
|
Tagging subscribers to this area: @dotnet/area-system-directoryservices |
Co-authored-by: Copilot <[email protected]> Copilot-Session: f86ef291-922b-46a2-bed8-98845b7c4e0e
Co-authored-by: Copilot <[email protected]> Copilot-Session: f86ef291-922b-46a2-bed8-98845b7c4e0e
Member
Author
|
Not sure who ask a review for, perhaps @jkoritzinsky? |
jkotas
approved these changes
Oct 28, 2026
jkoritzinsky
approved these changes
Oct 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
LDAP_TIMEVAL was declared with two 32-bit ints, which is the Windows LDAP_TIMEVAL (LONG fields). The same struct is passed by reference to OpenLDAP (ldap_set_option(LDAP_OPT_NETWORK_TIMEOUT), ldap_result, ldap_search_ext), which expects a struct timeval of time_t/suseconds_t, i.e. two C longs (16 bytes on LP64). OpenLDAP therefore read 8 bytes past the managed struct and interpreted tv_sec and tv_usec of the managed value together as its 64-bit tv_sec. As a result LdapConnection.Timeout was not honored (a connection attempt to an unreachable host only failed after the OS TCP timeout) and a search time limit was only correct by accident.
Declare the fields as CLong, which is a 32-bit LONG on Windows (unchanged layout) and a 64-bit long on LP64 Unix, matching both native definitions with a single type.