mirror of
https://github.com/curl/curl.git
synced 2026-08-26 18:13:37 +03:00
ldap: avoid null ptr deref on failure
ldap_get_dn() can return NULL on error Reported-by: Joshua Rogers Closes #18988
This commit is contained in:
parent
0d560d00fa
commit
69efbcaa03
1 changed files with 12 additions and 24 deletions
36
lib/ldap.c
36
lib/ldap.c
|
|
@ -535,7 +535,7 @@ static CURLcode ldap_do(struct Curl_easy *data, bool *done)
|
||||||
/* Get the DN and write it to the client */
|
/* Get the DN and write it to the client */
|
||||||
{
|
{
|
||||||
char *name;
|
char *name;
|
||||||
size_t name_len;
|
size_t name_len = 0;
|
||||||
#ifdef USE_WIN32_LDAP
|
#ifdef USE_WIN32_LDAP
|
||||||
TCHAR *dn = ldap_get_dn(server, entryIterator);
|
TCHAR *dn = ldap_get_dn(server, entryIterator);
|
||||||
name = curlx_convert_tchar_to_UTF8(dn);
|
name = curlx_convert_tchar_to_UTF8(dn);
|
||||||
|
|
@ -549,32 +549,20 @@ static CURLcode ldap_do(struct Curl_easy *data, bool *done)
|
||||||
#else
|
#else
|
||||||
char *dn = name = ldap_get_dn(server, entryIterator);
|
char *dn = name = ldap_get_dn(server, entryIterator);
|
||||||
#endif
|
#endif
|
||||||
name_len = strlen(name);
|
if(!name)
|
||||||
|
result = CURLE_FAILED_INIT;
|
||||||
result = Curl_client_write(data, CLIENTWRITE_BODY, "DN: ", 4);
|
else {
|
||||||
if(result) {
|
name_len = strlen(name);
|
||||||
FREE_ON_WINLDAP(name);
|
result = Curl_client_write(data, CLIENTWRITE_BODY, "DN: ", 4);
|
||||||
ldap_memfree(dn);
|
|
||||||
goto quit;
|
|
||||||
}
|
}
|
||||||
|
if(!result)
|
||||||
result = Curl_client_write(data, CLIENTWRITE_BODY, name, name_len);
|
result = Curl_client_write(data, CLIENTWRITE_BODY, name, name_len);
|
||||||
if(result) {
|
if(!result)
|
||||||
FREE_ON_WINLDAP(name);
|
result = Curl_client_write(data, CLIENTWRITE_BODY, "\n", 1);
|
||||||
ldap_memfree(dn);
|
|
||||||
goto quit;
|
|
||||||
}
|
|
||||||
|
|
||||||
result = Curl_client_write(data, CLIENTWRITE_BODY, "\n", 1);
|
|
||||||
if(result) {
|
|
||||||
FREE_ON_WINLDAP(name);
|
|
||||||
ldap_memfree(dn);
|
|
||||||
|
|
||||||
goto quit;
|
|
||||||
}
|
|
||||||
|
|
||||||
FREE_ON_WINLDAP(name);
|
FREE_ON_WINLDAP(name);
|
||||||
ldap_memfree(dn);
|
ldap_memfree(dn);
|
||||||
|
if(result)
|
||||||
|
goto quit;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get the attributes and write them to the client */
|
/* Get the attributes and write them to the client */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue