@@ -2583,6 +2583,12 @@ PHP_FUNCTION(socket_addrinfo_lookup)
25832583
25842584 memset (& hints , 0 , sizeof (hints ));
25852585
2586+ #if defined(PHP_WIN32 )
2587+ # if !defined(AF_MAX )
2588+ # define AF_MAX (AF_BTH + 1 )
2589+ # endif
2590+ #endif
2591+
25862592 if (zhints && !HT_IS_PACKED (Z_ARRVAL_P (zhints ))) {
25872593 ZEND_HASH_MAP_FOREACH_STR_KEY_VAL (Z_ARRVAL_P (zhints ), key , hint ) {
25882594 if (key ) {
@@ -2593,27 +2599,43 @@ PHP_FUNCTION(socket_addrinfo_lookup)
25932599 zend_argument_type_error (3 , "\"ai_flags \" key must be of type int , %s given ", zend_zval_type_name (hint ));
25942600 RETURN_THROWS ();
25952601 }
2602+ if (val < 0 || val > INT_MAX ) {
2603+ zend_argument_value_error (3 , "\"ai_flags\" key must be between 0 and %d" , INT_MAX );
2604+ RETURN_THROWS ();
2605+ }
25962606 hints .ai_flags = (int )val ;
25972607 } else if (zend_string_equals_literal (key , "ai_socktype ")) {
25982608 zend_long val = zval_try_get_long (hint , & failed );
25992609 if (failed ) {
26002610 zend_argument_type_error (3 , "\"ai_socktype\" key must be of type int, %s given" , zend_zval_type_name (hint ));
26012611 RETURN_THROWS ();
26022612 }
2613+ if (val < 0 || val > INT_MAX ) {
2614+ zend_argument_value_error (3 , "\"ai_socktype\" key must be between 0 and %d" , INT_MAX );
2615+ RETURN_THROWS ();
2616+ }
26032617 hints .ai_socktype = (int )val ;
26042618 } else if (zend_string_equals_literal (key , "ai_protocol ")) {
26052619 zend_long val = zval_try_get_long (hint , & failed );
26062620 if (failed ) {
26072621 zend_argument_type_error (3 , "\"ai_protocol\" key must be of type int, %s given" , zend_zval_type_name (hint ));
26082622 RETURN_THROWS ();
26092623 }
2624+ if (val < 0 || val > INT_MAX ) {
2625+ zend_argument_value_error (3 , "\"ai_protocol\" key must be between 0 and %d" , INT_MAX );
2626+ RETURN_THROWS ();
2627+ }
26102628 hints .ai_protocol = (int )val ;
26112629 } else if (zend_string_equals_literal (key , "ai_family ")) {
26122630 zend_long val = zval_try_get_long (hint , & failed );
26132631 if (failed ) {
26142632 zend_argument_type_error (3 , "\"ai_family\" key must be of type int, %s given" , zend_zval_type_name (hint ));
26152633 RETURN_THROWS ();
26162634 }
2635+ if (val < 0 || val >= AF_MAX ) {
2636+ zend_argument_value_error (3 , "\"ai_family\" key must be between 0 and %d" , AF_MAX - 1 );
2637+ RETURN_THROWS ();
2638+ }
26172639 hints .ai_family = (int )val ;
26182640 } else {
26192641 zend_argument_value_error (3 , "must only contain array keys \"ai_flags\", \"ai_socktype\", "
0 commit comments