@@ -1102,18 +1102,6 @@ static int _get_lderrno(LDAP *ldap)
1102
1102
}
1103
1103
/* }}} */
1104
1104
1105
- /* {{{ _set_lderrno */
1106
- static void _set_lderrno (LDAP * ldap , int lderr )
1107
- {
1108
- #if LDAP_API_VERSION > 2000 || defined(HAVE_ORALDAP )
1109
- /* New versions of OpenLDAP do it this way */
1110
- ldap_set_option (ldap , LDAP_OPT_ERROR_NUMBER , & lderr );
1111
- #else
1112
- ldap -> ld_errno = lderr ;
1113
- #endif
1114
- }
1115
- /* }}} */
1116
-
1117
1105
/* {{{ Bind to LDAP directory */
1118
1106
PHP_FUNCTION (ldap_bind )
1119
1107
{
@@ -1123,25 +1111,13 @@ PHP_FUNCTION(ldap_bind)
1123
1111
ldap_linkdata * ld ;
1124
1112
int rc ;
1125
1113
1126
- if (zend_parse_parameters (ZEND_NUM_ARGS (), "O|s!s !" , & link , ldap_link_ce , & ldap_bind_dn , & ldap_bind_dnlen , & ldap_bind_pw , & ldap_bind_pwlen ) != SUCCESS ) {
1114
+ if (zend_parse_parameters (ZEND_NUM_ARGS (), "O|p!p !" , & link , ldap_link_ce , & ldap_bind_dn , & ldap_bind_dnlen , & ldap_bind_pw , & ldap_bind_pwlen ) != SUCCESS ) {
1127
1115
RETURN_THROWS ();
1128
1116
}
1129
1117
1130
1118
ld = Z_LDAP_LINK_P (link );
1131
1119
VERIFY_LDAP_LINK_CONNECTED (ld );
1132
1120
1133
- if (ldap_bind_dn != NULL && memchr (ldap_bind_dn , '\0' , ldap_bind_dnlen ) != NULL ) {
1134
- _set_lderrno (ld -> link , LDAP_INVALID_CREDENTIALS );
1135
- zend_argument_type_error (2 , "must not contain null bytes" );
1136
- RETURN_THROWS ();
1137
- }
1138
-
1139
- if (ldap_bind_pw != NULL && memchr (ldap_bind_pw , '\0' , ldap_bind_pwlen ) != NULL ) {
1140
- _set_lderrno (ld -> link , LDAP_INVALID_CREDENTIALS );
1141
- zend_argument_type_error (3 , "must not contain null bytes" );
1142
- RETURN_THROWS ();
1143
- }
1144
-
1145
1121
{
1146
1122
#ifdef LDAP_API_FEATURE_X_OPENLDAP
1147
1123
/* ldap_simple_bind_s() is deprecated, use ldap_sasl_bind_s() instead.
@@ -1179,25 +1155,13 @@ PHP_FUNCTION(ldap_bind_ext)
1179
1155
LDAPMessage * ldap_res ;
1180
1156
int rc ;
1181
1157
1182
- if (zend_parse_parameters (ZEND_NUM_ARGS (), "O|s!s !a!" , & link , ldap_link_ce , & ldap_bind_dn , & ldap_bind_dnlen , & ldap_bind_pw , & ldap_bind_pwlen , & serverctrls ) != SUCCESS ) {
1158
+ if (zend_parse_parameters (ZEND_NUM_ARGS (), "O|p!p !a!" , & link , ldap_link_ce , & ldap_bind_dn , & ldap_bind_dnlen , & ldap_bind_pw , & ldap_bind_pwlen , & serverctrls ) != SUCCESS ) {
1183
1159
RETURN_THROWS ();
1184
1160
}
1185
1161
1186
1162
ld = Z_LDAP_LINK_P (link );
1187
1163
VERIFY_LDAP_LINK_CONNECTED (ld );
1188
1164
1189
- if (ldap_bind_dn != NULL && memchr (ldap_bind_dn , '\0' , ldap_bind_dnlen ) != NULL ) {
1190
- _set_lderrno (ld -> link , LDAP_INVALID_CREDENTIALS );
1191
- zend_argument_type_error (2 , "must not contain null bytes" );
1192
- RETURN_THROWS ();
1193
- }
1194
-
1195
- if (ldap_bind_pw != NULL && memchr (ldap_bind_pw , '\0' , ldap_bind_pwlen ) != NULL ) {
1196
- _set_lderrno (ld -> link , LDAP_INVALID_CREDENTIALS );
1197
- zend_argument_type_error (3 , "must not contain null bytes" );
1198
- RETURN_THROWS ();
1199
- }
1200
-
1201
1165
if (serverctrls ) {
1202
1166
lserverctrls = _php_ldap_controls_from_array (ld -> link , serverctrls , 4 );
1203
1167
if (lserverctrls == NULL ) {
@@ -1342,7 +1306,18 @@ PHP_FUNCTION(ldap_sasl_bind)
1342
1306
size_t rc , dn_len , passwd_len , mech_len , realm_len , authc_id_len , authz_id_len , props_len ;
1343
1307
php_ldap_bictx * ctx ;
1344
1308
1345
- if (zend_parse_parameters (ZEND_NUM_ARGS (), "O|s!s!s!s!s!s!s!" , & link , ldap_link_ce , & 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 ) {
1309
+ if (zend_parse_parameters (ZEND_NUM_ARGS (), "O|p!p!p!p!p!p!p!" ,
1310
+ & link , ldap_link_ce ,
1311
+ & binddn , & dn_len ,
1312
+ & passwd , & passwd_len ,
1313
+ & sasl_mech , & mech_len ,
1314
+ & sasl_realm , & realm_len ,
1315
+ & sasl_authc_id ,
1316
+ & authc_id_len ,
1317
+ & sasl_authz_id ,
1318
+ & authz_id_len ,
1319
+ & props , & props_len
1320
+ ) != SUCCESS ) {
1346
1321
RETURN_THROWS ();
1347
1322
}
1348
1323
@@ -1521,6 +1496,7 @@ static void php_ldap_do_search(INTERNAL_FUNCTION_PARAMETERS, int scope)
1521
1496
ret = 0 ;
1522
1497
goto cleanup ;
1523
1498
}
1499
+ // TODO check filter does not have any nul bytes
1524
1500
}
1525
1501
1526
1502
if (filter_ht ) {
@@ -1534,6 +1510,7 @@ static void php_ldap_do_search(INTERNAL_FUNCTION_PARAMETERS, int scope)
1534
1510
} else {
1535
1511
nfilters = 0 ; /* this means string, not array */
1536
1512
ldap_filter = zend_string_copy (filter_str );
1513
+ // TODO check filter does not have any nul bytes
1537
1514
}
1538
1515
1539
1516
lds = safe_emalloc (nlinks , sizeof (ldap_linkdata ), 0 );
@@ -1564,6 +1541,7 @@ static void php_ldap_do_search(INTERNAL_FUNCTION_PARAMETERS, int scope)
1564
1541
ret = 0 ;
1565
1542
goto cleanup_parallel ;
1566
1543
}
1544
+ // TODO check dn does not have any nul bytes
1567
1545
}
1568
1546
if (nfilters != 0 ) { /* filter an array? */
1569
1547
entry = zend_hash_get_current_data (filter_ht );
@@ -1573,6 +1551,7 @@ static void php_ldap_do_search(INTERNAL_FUNCTION_PARAMETERS, int scope)
1573
1551
ret = 0 ;
1574
1552
goto cleanup_parallel ;
1575
1553
}
1554
+ // TODO check filter does not have any nul bytes
1576
1555
}
1577
1556
1578
1557
if (serverctrls ) {
@@ -2059,7 +2038,7 @@ PHP_FUNCTION(ldap_get_values_len)
2059
2038
int i , num_values ;
2060
2039
size_t attr_len ;
2061
2040
2062
- if (zend_parse_parameters (ZEND_NUM_ARGS (), "OOs " , & link , ldap_link_ce , & result_entry , ldap_result_entry_ce , & attr , & attr_len ) != SUCCESS ) {
2041
+ if (zend_parse_parameters (ZEND_NUM_ARGS (), "OOp " , & link , ldap_link_ce , & result_entry , ldap_result_entry_ce , & attr , & attr_len ) != SUCCESS ) {
2063
2042
RETURN_THROWS ();
2064
2043
}
2065
2044
@@ -2125,7 +2104,7 @@ PHP_FUNCTION(ldap_explode_dn)
2125
2104
int i , count ;
2126
2105
size_t dn_len ;
2127
2106
2128
- if (zend_parse_parameters (ZEND_NUM_ARGS (), "sl " , & dn , & dn_len , & with_attrib ) != SUCCESS ) {
2107
+ if (zend_parse_parameters (ZEND_NUM_ARGS (), "pl " , & dn , & dn_len , & with_attrib ) != SUCCESS ) {
2129
2108
RETURN_THROWS ();
2130
2109
}
2131
2110
@@ -2155,7 +2134,7 @@ PHP_FUNCTION(ldap_dn2ufn)
2155
2134
char * dn , * ufn ;
2156
2135
size_t dn_len ;
2157
2136
2158
- if (zend_parse_parameters (ZEND_NUM_ARGS (), "s " , & dn , & dn_len ) != SUCCESS ) {
2137
+ if (zend_parse_parameters (ZEND_NUM_ARGS (), "p " , & dn , & dn_len ) != SUCCESS ) {
2159
2138
RETURN_THROWS ();
2160
2139
}
2161
2140
@@ -2193,7 +2172,7 @@ static void php_ldap_do_modify(INTERNAL_FUNCTION_PARAMETERS, int oper, int ext)
2193
2172
zend_ulong index ;
2194
2173
int is_full_add = 0 ; /* flag for full add operation so ldap_mod_add can be put back into oper, gerrit THomson */
2195
2174
2196
- if (zend_parse_parameters (ZEND_NUM_ARGS (), "Osa /|a!" , & link , ldap_link_ce , & dn , & dn_len , & entry , & serverctrls ) != SUCCESS ) {
2175
+ if (zend_parse_parameters (ZEND_NUM_ARGS (), "Opa /|a!" , & link , ldap_link_ce , & dn , & dn_len , & entry , & serverctrls ) != SUCCESS ) {
2197
2176
RETURN_THROWS ();
2198
2177
}
2199
2178
@@ -2428,7 +2407,7 @@ static void php_ldap_do_delete(INTERNAL_FUNCTION_PARAMETERS, int ext)
2428
2407
int rc , msgid ;
2429
2408
size_t dn_len ;
2430
2409
2431
- if (zend_parse_parameters (ZEND_NUM_ARGS (), "Os |a!" , & link , ldap_link_ce , & dn , & dn_len , & serverctrls ) != SUCCESS ) {
2410
+ if (zend_parse_parameters (ZEND_NUM_ARGS (), "Op |a!" , & link , ldap_link_ce , & dn , & dn_len , & serverctrls ) != SUCCESS ) {
2432
2411
RETURN_THROWS ();
2433
2412
}
2434
2413
@@ -2525,20 +2504,14 @@ PHP_FUNCTION(ldap_modify_batch)
2525
2504
];
2526
2505
*/
2527
2506
2528
- if (zend_parse_parameters (ZEND_NUM_ARGS (), "Osh /|a!" , & link , ldap_link_ce , & dn , & dn_len , & modifications , & server_controls_zv ) != SUCCESS ) {
2507
+ if (zend_parse_parameters (ZEND_NUM_ARGS (), "Oph /|a!" , & link , ldap_link_ce , & dn , & dn_len , & modifications , & server_controls_zv ) != SUCCESS ) {
2529
2508
RETURN_THROWS ();
2530
2509
}
2531
2510
2532
2511
ldap_linkdata * ld = Z_LDAP_LINK_P (link );
2533
2512
VERIFY_LDAP_LINK_CONNECTED (ld );
2534
2513
2535
2514
/* perform validation */
2536
- /* make sure the DN contains no NUL bytes */
2537
- if (zend_char_has_nul_byte (dn , dn_len )) {
2538
- zend_argument_value_error (2 , "must not contain null bytes" );
2539
- RETURN_THROWS ();
2540
- }
2541
-
2542
2515
/* make sure the top level is a normal array */
2543
2516
if (zend_hash_num_elements (modifications ) == 0 ) {
2544
2517
zend_argument_must_not_be_empty_error (3 );
@@ -2819,14 +2792,20 @@ PHP_FUNCTION(ldap_compare)
2819
2792
{
2820
2793
zval * serverctrls = NULL ;
2821
2794
zval * link ;
2822
- char * dn , * attr , * value ;
2823
- size_t dn_len , attr_len , value_len ;
2795
+ char * dn , * attr ;
2796
+ size_t dn_len , attr_len ;
2824
2797
ldap_linkdata * ld ;
2825
2798
LDAPControl * * lserverctrls = NULL ;
2826
2799
int ldap_errno ;
2827
2800
struct berval lvalue ;
2828
2801
2829
- if (zend_parse_parameters (ZEND_NUM_ARGS (), "Osss|a!" , & link , ldap_link_ce , & dn , & dn_len , & attr , & attr_len , & value , & value_len , & serverctrls ) != SUCCESS ) {
2802
+ if (zend_parse_parameters (ZEND_NUM_ARGS (), "Opps|a!" ,
2803
+ & link , ldap_link_ce ,
2804
+ & dn , & dn_len ,
2805
+ & attr , & attr_len ,
2806
+ & lvalue .bv_val , & lvalue .bv_len ,
2807
+ & serverctrls
2808
+ ) != SUCCESS ) {
2830
2809
RETURN_THROWS ();
2831
2810
}
2832
2811
@@ -2841,9 +2820,6 @@ PHP_FUNCTION(ldap_compare)
2841
2820
}
2842
2821
}
2843
2822
2844
- lvalue .bv_val = value ;
2845
- lvalue .bv_len = value_len ;
2846
-
2847
2823
ldap_errno = ldap_compare_ext_s (ld -> link , dn , attr , & lvalue , lserverctrls , NULL );
2848
2824
2849
2825
switch (ldap_errno ) {
@@ -3489,7 +3465,7 @@ static void php_ldap_do_rename(INTERNAL_FUNCTION_PARAMETERS, int ext)
3489
3465
size_t dn_len , newrdn_len , newparent_len ;
3490
3466
bool deleteoldrdn ;
3491
3467
3492
- if (zend_parse_parameters (ZEND_NUM_ARGS (), "Osssb |a!" , & link , ldap_link_ce , & dn , & dn_len , & newrdn , & newrdn_len , & newparent , & newparent_len , & deleteoldrdn , & serverctrls ) != SUCCESS ) {
3468
+ if (zend_parse_parameters (ZEND_NUM_ARGS (), "Opppb |a!" , & link , ldap_link_ce , & dn , & dn_len , & newrdn , & newrdn_len , & newparent , & newparent_len , & deleteoldrdn , & serverctrls ) != SUCCESS ) {
3493
3469
RETURN_THROWS ();
3494
3470
}
3495
3471
@@ -3827,7 +3803,7 @@ static void php_ldap_exop(INTERNAL_FUNCTION_PARAMETERS, bool force_sync) {
3827
3803
}
3828
3804
}
3829
3805
3830
- if (zend_parse_parameters (ZEND_NUM_ARGS (), "OS |S!a!zz" , & link , ldap_link_ce , & reqoid , & reqdata , & serverctrls , & retdata , & retoid ) != SUCCESS ) {
3806
+ if (zend_parse_parameters (ZEND_NUM_ARGS (), "OP |S!a!zz" , & link , ldap_link_ce , & reqoid , & reqdata , & serverctrls , & retdata , & retoid ) != SUCCESS ) {
3831
3807
RETURN_THROWS ();
3832
3808
}
3833
3809
0 commit comments