Skip to content

ext/ldap parameter fixes #6153

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 16 commits into from
Closed
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions ext/ldap/ldap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1001,15 +1001,15 @@ PHP_FUNCTION(ldap_connect)
WRONG_PARAM_COUNT;
}

if (zend_parse_parameters(ZEND_NUM_ARGS(), "|slssl", &host, &hostlen, &port, &wallet, &walletlen, &walletpasswd, &walletpasswdlen, &authmode) != SUCCESS) {
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|s!lssl", &host, &hostlen, &port, &wallet, &walletlen, &walletpasswd, &walletpasswdlen, &authmode) != SUCCESS) {
RETURN_THROWS();
}

if (ZEND_NUM_ARGS() == 5) {
ssl = 1;
}
#else
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|sl", &host, &hostlen, &port) != SUCCESS) {
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|s!l", &host, &hostlen, &port) != SUCCESS) {
RETURN_THROWS();
}
#endif
Expand Down Expand Up @@ -1119,7 +1119,7 @@ PHP_FUNCTION(ldap_bind)
ldap_linkdata *ld;
int rc;

if (zend_parse_parameters(ZEND_NUM_ARGS(), "r|ss", &link, &ldap_bind_dn, &ldap_bind_dnlen, &ldap_bind_pw, &ldap_bind_pwlen) != SUCCESS) {
if (zend_parse_parameters(ZEND_NUM_ARGS(), "r|s!s!", &link, &ldap_bind_dn, &ldap_bind_dnlen, &ldap_bind_pw, &ldap_bind_pwlen) != SUCCESS) {
RETURN_THROWS();
}

Expand Down Expand Up @@ -1175,7 +1175,7 @@ PHP_FUNCTION(ldap_bind_ext)
LDAPMessage *ldap_res;
int rc;

if (zend_parse_parameters(ZEND_NUM_ARGS(), "r|ssa", &link, &ldap_bind_dn, &ldap_bind_dnlen, &ldap_bind_pw, &ldap_bind_pwlen, &serverctrls) != SUCCESS) {
if (zend_parse_parameters(ZEND_NUM_ARGS(), "r|s!s!a", &link, &ldap_bind_dn, &ldap_bind_dnlen, &ldap_bind_pw, &ldap_bind_pwlen, &serverctrls) != SUCCESS) {
RETURN_THROWS();
}

Expand Down Expand Up @@ -1337,7 +1337,7 @@ PHP_FUNCTION(ldap_sasl_bind)
size_t rc, dn_len, passwd_len, mech_len, realm_len, authc_id_len, authz_id_len, props_len;
php_ldap_bictx *ctx;

if (zend_parse_parameters(ZEND_NUM_ARGS(), "r|sssssss", &link, &binddn, &dn_len, &passwd, &passwd_len, &sasl_mech, &mech_len, &sasl_realm, &realm_len, &sasl_authc_id, &authc_id_len, &sasl_authz_id, &authz_id_len, &props, &props_len) != SUCCESS) {
if (zend_parse_parameters(ZEND_NUM_ARGS(), "r|s!s!s!s!s!s!s!", &link, &binddn, &dn_len, &passwd, &passwd_len, &sasl_mech, &mech_len, &sasl_realm, &realm_len, &sasl_authc_id, &authc_id_len, &sasl_authz_id, &authz_id_len, &props, &props_len) != SUCCESS) {
RETURN_THROWS();
}

Expand Down Expand Up @@ -1601,12 +1601,12 @@ static void php_ldap_do_search(INTERNAL_FUNCTION_PARAMETERS, int scope)
}

if (!base_dn_str) {
zend_argument_type_error(2, "must be of type string when argument #1 ($link_identifier) is a resource");
zend_argument_type_error(2, "must be of type string when argument #1 ($ldap) is a resource");
}
ldap_base_dn = zend_string_copy(base_dn_str);

if (!filter_str) {
zend_argument_type_error(3, "must be of type string when argument #1 ($link_identifier) is a resource");
zend_argument_type_error(3, "must be of type string when argument #1 ($ldap) is a resource");
}
ldap_filter = zend_string_copy(filter_str);

Expand Down Expand Up @@ -1909,9 +1909,8 @@ PHP_FUNCTION(ldap_first_attribute)
ldap_linkdata *ld;
ldap_resultentry *resultentry;
char *attribute;
zend_long dummy_ber;

if (zend_parse_parameters(ZEND_NUM_ARGS(), "rr|l", &link, &result_entry, &dummy_ber) != SUCCESS) {
if (zend_parse_parameters(ZEND_NUM_ARGS(), "rr", &link, &result_entry) != SUCCESS) {
RETURN_THROWS();
}

Expand Down Expand Up @@ -1941,9 +1940,8 @@ PHP_FUNCTION(ldap_next_attribute)
ldap_linkdata *ld;
ldap_resultentry *resultentry;
char *attribute;
zend_long dummy_ber;

if (zend_parse_parameters(ZEND_NUM_ARGS(), "rr|l", &link, &result_entry, &dummy_ber) != SUCCESS) {
if (zend_parse_parameters(ZEND_NUM_ARGS(), "rr", &link, &result_entry) != SUCCESS) {
RETURN_THROWS();
}

Expand Down
Loading