@@ -2586,14 +2586,35 @@ PHP_FUNCTION(socket_addrinfo_lookup)
2586
2586
if (zhints && !HT_IS_PACKED (Z_ARRVAL_P (zhints ))) {
2587
2587
ZEND_HASH_MAP_FOREACH_STR_KEY_VAL (Z_ARRVAL_P (zhints ), key , hint ) {
2588
2588
if (key ) {
2589
+ bool failed = false;
2589
2590
if (zend_string_equals_literal (key , "ai_flags ")) {
2590
- hints .ai_flags = zval_get_long (hint );
2591
+ zend_long val = zval_try_get_long (hint , & failed );
2592
+ if (failed ) {
2593
+ zend_argument_type_error (3 , "\"ai_flags \" key must be of type int , %s given ", zend_zval_type_name (hint ));
2594
+ RETURN_THROWS ();
2595
+ }
2596
+ hints .ai_flags = (int )val ;
2591
2597
} else if (zend_string_equals_literal (key , "ai_socktype ")) {
2592
- hints .ai_socktype = zval_get_long (hint );
2598
+ zend_long val = zval_try_get_long (hint , & failed );
2599
+ if (failed ) {
2600
+ zend_argument_type_error (3 , "\"ai_socktype\" key must be of type int, %s given" , zend_zval_type_name (hint ));
2601
+ RETURN_THROWS ();
2602
+ }
2603
+ hints .ai_socktype = (int )val ;
2593
2604
} else if (zend_string_equals_literal (key , "ai_protocol ")) {
2594
- hints .ai_protocol = zval_get_long (hint );
2605
+ zend_long val = zval_try_get_long (hint , & failed );
2606
+ if (failed ) {
2607
+ zend_argument_type_error (3 , "\"ai_protocol\" key must be of type int, %s given" , zend_zval_type_name (hint ));
2608
+ RETURN_THROWS ();
2609
+ }
2610
+ hints .ai_protocol = (int )val ;
2595
2611
} else if (zend_string_equals_literal (key , "ai_family ")) {
2596
- hints .ai_family = zval_get_long (hint );
2612
+ zend_long val = zval_try_get_long (hint , & failed );
2613
+ if (failed ) {
2614
+ zend_argument_type_error (3 , "\"ai_family\" key must be of type int, %s given" , zend_zval_type_name (hint ));
2615
+ RETURN_THROWS ();
2616
+ }
2617
+ hints .ai_family = (int )val ;
2597
2618
} else {
2598
2619
zend_argument_value_error (3 , "must only contain array keys \"ai_flags\", \"ai_socktype\", "
2599
2620
"\"ai_protocol\", or \"ai_family\"" );
0 commit comments