@@ -2586,14 +2586,35 @@ PHP_FUNCTION(socket_addrinfo_lookup)
25862586 if (zhints && !HT_IS_PACKED (Z_ARRVAL_P (zhints ))) {
25872587 ZEND_HASH_MAP_FOREACH_STR_KEY_VAL (Z_ARRVAL_P (zhints ), key , hint ) {
25882588 if (key ) {
2589+ bool failed = false;
25892590 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 ;
25912597 } 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 ;
25932604 } 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 ;
25952611 } 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 ;
25972618 } else {
25982619 zend_argument_value_error (3 , "must only contain array keys \"ai_flags\", \"ai_socktype\", "
25992620 "\"ai_protocol\", or \"ai_family\"" );
0 commit comments