static int _php_ldap_control_from_array(LDAP *ld, LDAPControl** ctrl, zval* array)
{
zval* val;
- zend_string *control_oid = NULL;
+ zend_string *control_oid;
int control_iscritical = 0, rc = LDAP_SUCCESS;
char** ldap_attrs = NULL;
LDAPSortKey** sort_keys = NULL;
} else {
tmpstring = zval_get_string(val);
if (EG(exception)) {
- return -1;
+ rc = -1;
+ goto failure;
}
control_value->bv_val = ZSTR_VAL(tmpstring);
control_value->bv_len = ZSTR_LEN(tmpstring);
php_error_docref(NULL, E_WARNING, "Failed to create assert control value: %s (%d)", ldap_err2string(rc), rc);
}
}
+ zend_string_release(assert);
}
} else if (strcmp(ZSTR_VAL(control_oid), LDAP_CONTROL_VALUESRETURNFILTER) == 0) {
zval* tmp;
}
failure:
+ zend_string_release(control_oid);
+ if (tmpstring != NULL) {
+ zend_string_release(tmpstring);
+ }
if (control_value != NULL) {
ber_memfree(control_value);
control_value = NULL;
{
zval *link, *base_dn, *filter, *attrs = NULL, *attr, *serverctrls = NULL;
zend_long attrsonly, sizelimit, timelimit, deref;
- zend_string *ldap_filter = NULL, *ldap_base_dn = NULL, *tmpstring;
+ zend_string *ldap_filter = NULL, *ldap_base_dn = NULL;
char **ldap_attrs = NULL;
ldap_linkdata *ld = NULL;
LDAPMessage *ldap_res;
int old_ldap_sizelimit = -1, old_ldap_timelimit = -1, old_ldap_deref = -1;
int num_attribs = 0, ret = 1, i, errno, argcount = ZEND_NUM_ARGS();
- if (zend_parse_parameters(argcount, "zzz|alllla", &link, &base_dn, &filter, &attrs, &attrsonly,
+ if (zend_parse_parameters(argcount, "zzz|alllla/", &link, &base_dn, &filter, &attrs, &attrsonly,
&sizelimit, &timelimit, &deref, &serverctrls) == FAILURE) {
return;
}
goto cleanup;
}
- tmpstring = zval_get_string(attr);
+ convert_to_string(attr);
if (EG(exception)) {
ret = 0;
goto cleanup;
}
- ldap_attrs[i] = ZSTR_VAL(tmpstring);
+ ldap_attrs[i] = Z_STRVAL_P(attr);
}
ldap_attrs[num_attribs] = NULL;
default:
/* Restoring previous options */
php_set_opts(ld->link, old_ldap_sizelimit, old_ldap_timelimit, old_ldap_deref, &ldap_sizelimit, &ldap_timelimit, &ldap_deref);
}
+ if (ldap_filter) {
+ zend_string_release(ldap_filter);
+ }
+ if (ldap_base_dn) {
+ zend_string_release(ldap_base_dn);
+ }
if (ldap_attrs != NULL) {
efree(ldap_attrs);
}
int i, j, num_attribs, num_values, msgid;
size_t dn_len;
int *num_berval;
- zend_string *attribute, *tmpstring;
+ zend_string *attribute;
zend_ulong index;
int is_full_add=0; /* flag for full add operation so ldap_mod_add can be put back into oper, gerrit THomson */
/* allow for arrays with one element, no allowance for arrays with none but probably not required, gerrit thomson. */
if ((num_values == 1) && (Z_TYPE_P(value) != IS_ARRAY)) {
- tmpstring = zval_get_string(value);
+ convert_to_string(value);
if (EG(exception)) {
RETVAL_FALSE;
goto cleanup;
}
ldap_mods[i]->mod_bvalues[0] = (struct berval *) emalloc (sizeof(struct berval));
- ldap_mods[i]->mod_bvalues[0]->bv_val = ZSTR_VAL(tmpstring);
- ldap_mods[i]->mod_bvalues[0]->bv_len = ZSTR_LEN(tmpstring);
+ ldap_mods[i]->mod_bvalues[0]->bv_val = Z_STRVAL_P(value);
+ ldap_mods[i]->mod_bvalues[0]->bv_len = Z_STRLEN_P(value);
} else {
for (j = 0; j < num_values; j++) {
if ((ivalue = zend_hash_index_find(Z_ARRVAL_P(value), j)) == NULL) {
RETVAL_FALSE;
goto cleanup;
}
- tmpstring = zval_get_string(ivalue);
+ convert_to_string(ivalue);
if (EG(exception)) {
RETVAL_FALSE;
goto cleanup;
}
ldap_mods[i]->mod_bvalues[j] = (struct berval *) emalloc (sizeof(struct berval));
- ldap_mods[i]->mod_bvalues[j]->bv_val = ZSTR_VAL(tmpstring);
- ldap_mods[i]->mod_bvalues[j]->bv_len = ZSTR_LEN(tmpstring);
+ ldap_mods[i]->mod_bvalues[j]->bv_val = Z_STRVAL_P(ivalue);
+ ldap_mods[i]->mod_bvalues[j]->bv_len = Z_STRLEN_P(ivalue);
}
}
ldap_mods[i]->mod_bvalues[num_values] = NULL;
/* fill it */
ldap_mods[i]->mod_bvalues[j]->bv_len = ZSTR_LEN(modval);
ldap_mods[i]->mod_bvalues[j]->bv_val = estrndup(ZSTR_VAL(modval), ZSTR_LEN(modval));
+ zend_string_release(modval);
}
/* NULL-terminate values */
}
RETURN_FALSE;
}
+ zval_ptr_dtor(retval);
_php_ldap_controls_to_array(ld->link, ctrls, retval, 1);
} break;
/* options not implemented
RETURN_FALSE;
}
if (ldap_set_option(ldap, option, ZSTR_VAL(val))) {
+ zend_string_release(val);
RETURN_FALSE;
}
+ zend_string_release(val);
} break;
/* options with boolean value */
case LDAP_OPT_REFERRALS: