@@ -2749,8 +2749,7 @@ PHP_FUNCTION(socket_export_stream)
27492749/* {{{ Gets array with contents of getaddrinfo about the given hostname. */
27502750PHP_FUNCTION (socket_addrinfo_lookup )
27512751{
2752- char * service = NULL ;
2753- size_t service_len = 0 ;
2752+ zend_string * service = NULL ;
27542753 zend_string * hostname , * key ;
27552754 zval * hint , * zhints = NULL ;
27562755
@@ -2760,7 +2759,7 @@ PHP_FUNCTION(socket_addrinfo_lookup)
27602759 ZEND_PARSE_PARAMETERS_START (1 , 3 )
27612760 Z_PARAM_STR (hostname )
27622761 Z_PARAM_OPTIONAL
2763- Z_PARAM_STRING_OR_NULL (service , service_len )
2762+ Z_PARAM_STR_OR_NULL (service )
27642763 Z_PARAM_ARRAY (zhints )
27652764 ZEND_PARSE_PARAMETERS_END ();
27662765
@@ -2824,14 +2823,16 @@ PHP_FUNCTION(socket_addrinfo_lookup)
28242823 // Some platforms support also PF_LOCAL/AF_UNIX (e.g. FreeBSD) but the security concerns implied
28252824 // make it not worth handling it (e.g. unwarranted write permissions on the socket).
28262825 // Note existing socket_addrinfo* api already forbid such case.
2826+ if (val != AF_UNSPEC ) {
28272827#ifdef HAVE_IPV6
2828- if (val != AF_INET && val != AF_INET6 ) {
2829- zend_argument_value_error (3 , "\"ai_family\" key must be AF_INET or AF_INET6" );
2828+ if (val != AF_INET && val != AF_INET6 ) {
2829+ zend_argument_value_error (3 , "\"ai_family\" key must be AF_INET or AF_INET6" );
28302830#else
2831- if (val != AF_INET ) {
2832- zend_argument_value_error (3 , "\"ai_family\" key must be AF_INET" );
2831+ if (val != AF_INET ) {
2832+ zend_argument_value_error (3 , "\"ai_family\" key must be AF_INET" );
28332833#endif
2834- RETURN_THROWS ();
2834+ RETURN_THROWS ();
2835+ }
28352836 }
28362837 hints .ai_family = (int )val ;
28372838 } else {
@@ -2847,15 +2848,19 @@ PHP_FUNCTION(socket_addrinfo_lookup)
28472848 } ZEND_HASH_FOREACH_END ();
28482849 }
28492850
2850- if (getaddrinfo (ZSTR_VAL (hostname ), service , & hints , & result ) != 0 ) {
2851+ if (getaddrinfo (ZSTR_VAL (hostname ), service ? ZSTR_VAL ( service ) : NULL , & hints , & result ) != 0 ) {
28512852 RETURN_FALSE ;
28522853 }
28532854
28542855 array_init (return_value );
28552856 zend_hash_real_init_packed (Z_ARRVAL_P (return_value ));
28562857
28572858 for (rp = result ; rp != NULL ; rp = rp -> ai_next ) {
2858- if (rp -> ai_family != AF_UNSPEC ) {
2859+ if (rp -> ai_family == AF_INET
2860+ #ifdef HAVE_IPV6
2861+ || rp -> ai_family == AF_INET6
2862+ #endif
2863+ ) {
28592864 zval zaddr ;
28602865
28612866 object_init_ex (& zaddr , address_info_ce );
0 commit comments