Do not try to dereference bindpw if it is null

Fixes: https://fedorahosted.org/freeipa/ticket/783
This commit is contained in:
Simo Sorce 2011-01-17 18:42:21 -05:00
parent 01f907c01b
commit 8a6547943f

View File

@ -213,8 +213,13 @@ connect_ldap(const char *hostname, const char *binddn, const char *bindpw) {
goto fail;
}
bindpw_bv.bv_val = discard_const(bindpw);
bindpw_bv.bv_len = strlen(bindpw);
if (bindpw) {
bindpw_bv.bv_val = discard_const(bindpw);
bindpw_bv.bv_len = strlen(bindpw);
} else {
bindpw_bv.bv_val = NULL;
bindpw_bv.bv_len = 0;
}
ret = ldap_sasl_bind_s(ld, binddn, LDAP_SASL_SIMPLE, &bindpw_bv,
NULL, NULL, NULL);