@@ -1448,7 +1448,8 @@ static void php_ldap_do_search(INTERNAL_FUNCTION_PARAMETERS, int scope)
14481448 zend_string * base_dn_str = NULL ;
14491449 HashTable * filter_ht = NULL ;
14501450 zend_string * filter_str = NULL ;
1451- zend_long attrsonly , sizelimit , timelimit , deref ;
1451+ zend_long sizelimit = 0 , timelimit = 0 , deref = LDAP_DEREF_NEVER ;
1452+ bool attrsonly = false;
14521453 HashTable * server_controls_ht = NULL ;
14531454 char * * ldap_attrs = NULL ;
14541455 ldap_linkdata * ld = NULL ;
@@ -1465,13 +1466,28 @@ static void php_ldap_do_search(INTERNAL_FUNCTION_PARAMETERS, int scope)
14651466 Z_PARAM_ARRAY_HT_OR_STR (filter_ht , filter_str )
14661467 Z_PARAM_OPTIONAL
14671468 Z_PARAM_ARRAY_EX (attrs , 0 , 1 )
1468- Z_PARAM_LONG (attrsonly )
1469+ Z_PARAM_BOOL (attrsonly )
14691470 Z_PARAM_LONG (sizelimit )
14701471 Z_PARAM_LONG (timelimit )
14711472 Z_PARAM_LONG (deref )
14721473 Z_PARAM_ARRAY_HT_EX (server_controls_ht , 1 , 1 )
14731474 ZEND_PARSE_PARAMETERS_END ();
14741475
1476+ if (sizelimit < -1 || sizelimit > INT_MAX ) {
1477+ zend_argument_value_error (6 , "must be between -1 and %d" , INT_MAX );
1478+ RETURN_THROWS ();
1479+ }
1480+
1481+ if (timelimit < -1 || timelimit > INT_MAX ) {
1482+ zend_argument_value_error (7 , "must be between -1 and %d" , INT_MAX );
1483+ RETURN_THROWS ();
1484+ }
1485+
1486+ if (deref < LDAP_DEREF_NEVER || deref > LDAP_DEREF_ALWAYS ) {
1487+ zend_argument_value_error (8 , "must be one of the LDAP_DEREF_* constants" );
1488+ RETURN_THROWS ();
1489+ }
1490+
14751491 /* Reverse -> fall through */
14761492 switch (argcount ) {
14771493 case 9 :
@@ -1485,7 +1501,7 @@ static void php_ldap_do_search(INTERNAL_FUNCTION_PARAMETERS, int scope)
14851501 ldap_sizelimit = sizelimit ;
14861502 ZEND_FALLTHROUGH ;
14871503 case 5 :
1488- ldap_attrsonly = attrsonly ;
1504+ ldap_attrsonly = attrsonly ? 1 : 0 ;
14891505 ZEND_FALLTHROUGH ;
14901506 default :
14911507 break ;
0 commit comments