winldap: avoid NULL pointer deref on ldap_get_dn() fail#22000
Closed
vszakats wants to merge 4 commits into
Closed
Conversation
There was a problem hiding this comment.
Pull request overview
This PR hardens the WinLDAP code path in lib/ldap.c by preventing a NULL pointer from being passed into the curlx_convert_tchar_to_UTF8() conversion when ldap_get_dn() fails (notably affecting non-Unicode builds where the conversion maps to curlx_strdup()), and aligns formatting with surrounding code style.
Changes:
- Add a NULL check around the WinLDAP
ldap_get_dn()return value before attempting TCHAR→UTF-8 conversion. - Preserve existing error handling flow for “no DN available” (
CURLE_FAILED_INIT) while avoiding a crash. - Minor whitespace cleanup (removes extra blank lines).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
jay
reviewed
Jun 15, 2026
In non-Unicode builds.
jay
approved these changes
Jun 15, 2026
Member
There was a problem hiding this comment.
Ref: MicrosoftDocs/sdk-api#2222
MS documentation has incorrect return type PCHAR (char *) for many ldap functions. In fact they are closer to PTCHAR (wchar_t * if UNICODE, char * if not), so AFAICT we are as close as we can be to correct here.
Member
Author
|
Thanks @jay! |
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.
In non-Unicode builds.
Assisted-by: Jay Satiro
https://github.com/curl/curl/pull/22000/files?w=1