@@ -1448,7 +1448,8 @@ static void php_ldap_do_search(INTERNAL_FUNCTION_PARAMETERS, int scope)
1448
1448
zend_string * base_dn_str = NULL ;
1449
1449
HashTable * filter_ht = NULL ;
1450
1450
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;
1452
1453
HashTable * server_controls_ht = NULL ;
1453
1454
char * * ldap_attrs = NULL ;
1454
1455
ldap_linkdata * ld = NULL ;
@@ -1465,13 +1466,28 @@ static void php_ldap_do_search(INTERNAL_FUNCTION_PARAMETERS, int scope)
1465
1466
Z_PARAM_ARRAY_HT_OR_STR (filter_ht , filter_str )
1466
1467
Z_PARAM_OPTIONAL
1467
1468
Z_PARAM_ARRAY_EX (attrs , 0 , 1 )
1468
- Z_PARAM_LONG (attrsonly )
1469
+ Z_PARAM_BOOL (attrsonly )
1469
1470
Z_PARAM_LONG (sizelimit )
1470
1471
Z_PARAM_LONG (timelimit )
1471
1472
Z_PARAM_LONG (deref )
1472
1473
Z_PARAM_ARRAY_HT_EX (server_controls_ht , 1 , 1 )
1473
1474
ZEND_PARSE_PARAMETERS_END ();
1474
1475
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
+
1475
1491
/* Reverse -> fall through */
1476
1492
switch (argcount ) {
1477
1493
case 9 :
@@ -1485,7 +1501,7 @@ static void php_ldap_do_search(INTERNAL_FUNCTION_PARAMETERS, int scope)
1485
1501
ldap_sizelimit = sizelimit ;
1486
1502
ZEND_FALLTHROUGH ;
1487
1503
case 5 :
1488
- ldap_attrsonly = attrsonly ;
1504
+ ldap_attrsonly = attrsonly ? 1 : 0 ;
1489
1505
ZEND_FALLTHROUGH ;
1490
1506
default :
1491
1507
break ;
0 commit comments