Loading lib/ldap.c +40 −5 Original line number Diff line number Diff line Loading @@ -490,18 +490,32 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done) for(attribute = ldap_first_attribute(server, entryIterator, &ber); attribute; attribute = ldap_next_attribute(server, entryIterator, ber)) { BerValue **vals; size_t attr_len; #if defined(CURL_LDAP_WIN) size_t attr_len = _tcslen(attribute); char *attr = Curl_convert_tchar_to_UTF8(attribute); if(!attr) { if(ber) ber_free(ber, 0); result = CURLE_OUT_OF_MEMORY; goto quit; } #else size_t attr_len = strlen(attribute); char *attr = attribute; #endif BerValue **vals = ldap_get_values_len(server, entryIterator, attribute); attr_len = strlen(attr); vals = ldap_get_values_len(server, entryIterator, attribute); if(vals != NULL) { for(i = 0; (vals[i] != NULL); i++) { result = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\t", 1); if(result) { ldap_value_free_len(vals); #if defined(CURL_LDAP_WIN) Curl_unicodefree(attr); #endif ldap_memfree(attribute); if(ber) ber_free(ber, 0); Loading @@ -510,9 +524,12 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done) } result = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)attribute, attr_len); (char *) attr, attr_len); if(result) { ldap_value_free_len(vals); #if defined(CURL_LDAP_WIN) Curl_unicodefree(attr); #endif ldap_memfree(attribute); if(ber) ber_free(ber, 0); Loading @@ -523,6 +540,9 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done) result = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)": ", 2); if(result) { ldap_value_free_len(vals); #if defined(CURL_LDAP_WIN) Curl_unicodefree(attr); #endif ldap_memfree(attribute); if(ber) ber_free(ber, 0); Loading @@ -533,7 +553,7 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done) dlsize += attr_len + 3; if((attr_len > 7) && (strcmp(";binary", (char *) attribute + (attr_len - 7)) == 0)) { (strcmp(";binary", (char *) attr + (attr_len - 7)) == 0)) { /* Binary attribute, encode to base64. */ result = Curl_base64_encode(data, vals[i]->bv_val, Loading @@ -542,6 +562,9 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done) &val_b64_sz); if(result) { ldap_value_free_len(vals); #if defined(CURL_LDAP_WIN) Curl_unicodefree(attr); #endif ldap_memfree(attribute); if(ber) ber_free(ber, 0); Loading @@ -555,6 +578,9 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done) free(val_b64); if(result) { ldap_value_free_len(vals); #if defined(CURL_LDAP_WIN) Curl_unicodefree(attr); #endif ldap_memfree(attribute); if(ber) ber_free(ber, 0); Loading @@ -570,6 +596,9 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done) vals[i]->bv_len); if(result) { ldap_value_free_len(vals); #if defined(CURL_LDAP_WIN) Curl_unicodefree(attr); #endif ldap_memfree(attribute); if(ber) ber_free(ber, 0); Loading @@ -583,6 +612,9 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done) result = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\n", 1); if(result) { ldap_value_free_len(vals); #if defined(CURL_LDAP_WIN) Curl_unicodefree(attr); #endif ldap_memfree(attribute); if(ber) ber_free(ber, 0); Loading @@ -598,6 +630,9 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done) } /* Free the attribute as we are done with it */ #if defined(CURL_LDAP_WIN) Curl_unicodefree(attr); #endif ldap_memfree(attribute); result = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\n", 1); Loading Loading
lib/ldap.c +40 −5 Original line number Diff line number Diff line Loading @@ -490,18 +490,32 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done) for(attribute = ldap_first_attribute(server, entryIterator, &ber); attribute; attribute = ldap_next_attribute(server, entryIterator, ber)) { BerValue **vals; size_t attr_len; #if defined(CURL_LDAP_WIN) size_t attr_len = _tcslen(attribute); char *attr = Curl_convert_tchar_to_UTF8(attribute); if(!attr) { if(ber) ber_free(ber, 0); result = CURLE_OUT_OF_MEMORY; goto quit; } #else size_t attr_len = strlen(attribute); char *attr = attribute; #endif BerValue **vals = ldap_get_values_len(server, entryIterator, attribute); attr_len = strlen(attr); vals = ldap_get_values_len(server, entryIterator, attribute); if(vals != NULL) { for(i = 0; (vals[i] != NULL); i++) { result = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\t", 1); if(result) { ldap_value_free_len(vals); #if defined(CURL_LDAP_WIN) Curl_unicodefree(attr); #endif ldap_memfree(attribute); if(ber) ber_free(ber, 0); Loading @@ -510,9 +524,12 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done) } result = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)attribute, attr_len); (char *) attr, attr_len); if(result) { ldap_value_free_len(vals); #if defined(CURL_LDAP_WIN) Curl_unicodefree(attr); #endif ldap_memfree(attribute); if(ber) ber_free(ber, 0); Loading @@ -523,6 +540,9 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done) result = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)": ", 2); if(result) { ldap_value_free_len(vals); #if defined(CURL_LDAP_WIN) Curl_unicodefree(attr); #endif ldap_memfree(attribute); if(ber) ber_free(ber, 0); Loading @@ -533,7 +553,7 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done) dlsize += attr_len + 3; if((attr_len > 7) && (strcmp(";binary", (char *) attribute + (attr_len - 7)) == 0)) { (strcmp(";binary", (char *) attr + (attr_len - 7)) == 0)) { /* Binary attribute, encode to base64. */ result = Curl_base64_encode(data, vals[i]->bv_val, Loading @@ -542,6 +562,9 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done) &val_b64_sz); if(result) { ldap_value_free_len(vals); #if defined(CURL_LDAP_WIN) Curl_unicodefree(attr); #endif ldap_memfree(attribute); if(ber) ber_free(ber, 0); Loading @@ -555,6 +578,9 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done) free(val_b64); if(result) { ldap_value_free_len(vals); #if defined(CURL_LDAP_WIN) Curl_unicodefree(attr); #endif ldap_memfree(attribute); if(ber) ber_free(ber, 0); Loading @@ -570,6 +596,9 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done) vals[i]->bv_len); if(result) { ldap_value_free_len(vals); #if defined(CURL_LDAP_WIN) Curl_unicodefree(attr); #endif ldap_memfree(attribute); if(ber) ber_free(ber, 0); Loading @@ -583,6 +612,9 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done) result = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\n", 1); if(result) { ldap_value_free_len(vals); #if defined(CURL_LDAP_WIN) Curl_unicodefree(attr); #endif ldap_memfree(attribute); if(ber) ber_free(ber, 0); Loading @@ -598,6 +630,9 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done) } /* Free the attribute as we are done with it */ #if defined(CURL_LDAP_WIN) Curl_unicodefree(attr); #endif ldap_memfree(attribute); result = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\n", 1); Loading