@@ -2583,6 +2583,12 @@ PHP_FUNCTION(socket_addrinfo_lookup)
2583
2583
2584
2584
memset (& hints , 0 , sizeof (hints ));
2585
2585
2586
+ #if defined(PHP_WIN32 )
2587
+ # if !defined(AF_MAX )
2588
+ # define AF_MAX (AF_BTH + 1 )
2589
+ # endif
2590
+ #endif
2591
+
2586
2592
if (zhints && !HT_IS_PACKED (Z_ARRVAL_P (zhints ))) {
2587
2593
ZEND_HASH_MAP_FOREACH_STR_KEY_VAL (Z_ARRVAL_P (zhints ), key , hint ) {
2588
2594
if (key ) {
@@ -2593,27 +2599,43 @@ PHP_FUNCTION(socket_addrinfo_lookup)
2593
2599
zend_argument_type_error (3 , "\"ai_flags \" key must be of type int , %s given ", zend_zval_type_name (hint ));
2594
2600
RETURN_THROWS ();
2595
2601
}
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
+ }
2596
2606
hints .ai_flags = (int )val ;
2597
2607
} else if (zend_string_equals_literal (key , "ai_socktype ")) {
2598
2608
zend_long val = zval_try_get_long (hint , & failed );
2599
2609
if (failed ) {
2600
2610
zend_argument_type_error (3 , "\"ai_socktype\" key must be of type int, %s given" , zend_zval_type_name (hint ));
2601
2611
RETURN_THROWS ();
2602
2612
}
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
+ }
2603
2617
hints .ai_socktype = (int )val ;
2604
2618
} else if (zend_string_equals_literal (key , "ai_protocol ")) {
2605
2619
zend_long val = zval_try_get_long (hint , & failed );
2606
2620
if (failed ) {
2607
2621
zend_argument_type_error (3 , "\"ai_protocol\" key must be of type int, %s given" , zend_zval_type_name (hint ));
2608
2622
RETURN_THROWS ();
2609
2623
}
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
+ }
2610
2628
hints .ai_protocol = (int )val ;
2611
2629
} else if (zend_string_equals_literal (key , "ai_family ")) {
2612
2630
zend_long val = zval_try_get_long (hint , & failed );
2613
2631
if (failed ) {
2614
2632
zend_argument_type_error (3 , "\"ai_family\" key must be of type int, %s given" , zend_zval_type_name (hint ));
2615
2633
RETURN_THROWS ();
2616
2634
}
2635
+ if (val < 0 || val >= AF_MAX ) {
2636
+ zend_argument_value_error (3 , "\"ai_family\" key must be between 0 and %d" , AF_MAX );
2637
+ RETURN_THROWS ();
2638
+ }
2617
2639
hints .ai_family = (int )val ;
2618
2640
} else {
2619
2641
zend_argument_value_error (3 , "must only contain array keys \"ai_flags\", \"ai_socktype\", "
0 commit comments