1111
1212extern zend_result php_string_to_if_index (const char * val , unsigned * out );
1313
14- int php_set_common_addr (struct sockaddr * sin , int family , char * string , php_socket * php_sock ) /* {{{ */
14+ bool php_set_common_addr (struct sockaddr * sin , int family , zend_string * string , php_socket * php_sock ) /* {{{ */
1515{
1616#ifdef HAVE_GETADDRINFO
1717 struct sockaddr_in6 * sin6 = (struct sockaddr_in6 * )sin ;
@@ -22,9 +22,9 @@ int php_set_common_addr(struct sockaddr *sin, int family, char *string, php_sock
2222 struct addrinfo hints ;
2323 struct addrinfo * addrinfo = NULL ;
2424
25- if (family == AF_INET6 && inet_pton (AF_INET6 , string , & tmp6 )) {
25+ if (family == AF_INET6 && inet_pton (AF_INET6 , ZSTR_VAL ( string ) , & tmp6 )) {
2626 memcpy (& (sin6 -> sin6_addr .s6_addr ), & (tmp6 .s6_addr ), sizeof (struct in6_addr ));
27- } else if (family == AF_INET && inet_pton (AF_INET , string , & tmp4 )) {
27+ } else if (family == AF_INET && inet_pton (AF_INET , ZSTR_VAL ( string ) , & tmp4 )) {
2828 sin4 -> sin_addr .s_addr = tmp4 .s_addr ;
2929 } else {
3030 memset (& hints , 0 , sizeof (struct addrinfo ));
@@ -41,12 +41,12 @@ int php_set_common_addr(struct sockaddr *sin, int family, char *string, php_sock
4141#else
4242 PHP_SOCKET_ERROR (php_sock , "Host lookup failed" , (-10000 - h_errno ));
4343#endif
44- return 0 ;
44+ return false ;
4545 }
4646 if (addrinfo -> ai_family != family ) {
4747 php_error_docref (NULL , E_WARNING , "Host lookup failed: Wrong address family returned for socket" );
4848 freeaddrinfo (addrinfo );
49- return 0 ;
49+ return false ;
5050 }
5151
5252 if (addrinfo -> ai_family == AF_INET6 ) {
@@ -57,23 +57,23 @@ int php_set_common_addr(struct sockaddr *sin, int family, char *string, php_sock
5757 freeaddrinfo (addrinfo );
5858 }
5959
60- return 1 ;
60+ return true ;
6161#else
6262 php_error_docref (NULL , E_WARNING , "Host lookup failed: getaddrinfo() not available on this system" );
63- return 0 ;
63+ return true ;
6464#endif
6565}
6666/* }}} */
6767
6868#ifdef HAVE_IPV6
6969/* Sets addr by hostname, or by ip in string form (AF_INET6) */
70- int php_set_inet6_addr (struct sockaddr_in6 * sin6 , char * string , php_socket * php_sock ) /* {{{ */
70+ bool php_set_inet6_addr (struct sockaddr_in6 * sin6 , char * string , php_socket * php_sock ) /* {{{ */
7171{
72- char * scope = strchr (string , '%' );
72+ char * scope = strchr (ZSTR_VAL ( string ) , '%' );
7373
74- int ret = php_set_common_addr ((struct sockaddr * )sin6 , AF_INET6 , string , php_sock );
74+ bool ret = php_set_common_addr ((struct sockaddr * )sin6 , AF_INET6 , string , php_sock );
7575 if (!ret ) {
76- return 0 ;
76+ return false ;
7777 }
7878
7979 if (scope ) {
@@ -100,23 +100,23 @@ int php_set_inet6_addr(struct sockaddr_in6 *sin6, char *string, php_socket *php_
100100#endif
101101
102102/* Sets addr by hostname, or by ip in string form (AF_INET) */
103- int php_set_inet_addr (struct sockaddr_in * sin , zend_string * string , php_socket * php_sock ) /* {{{ */
103+ bool php_set_inet_addr (struct sockaddr_in * sin , zend_string * string , php_socket * php_sock ) /* {{{ */
104104{
105105 return php_set_common_addr ((struct sockaddr * )sin , AF_INET , string , php_sock );
106106}
107107/* }}} */
108108
109109/* Sets addr by hostname or by ip in string form (AF_INET or AF_INET6,
110110 * depending on the socket) */
111- int php_set_inet46_addr (php_sockaddr_storage * ss , socklen_t * ss_len , zend_string * string , php_socket * php_sock ) /* {{{ */
111+ bool php_set_inet46_addr (php_sockaddr_storage * ss , socklen_t * ss_len , zend_string * string , php_socket * php_sock ) /* {{{ */
112112{
113113 if (php_sock -> type == AF_INET ) {
114114 struct sockaddr_in t = {0 };
115115 if (php_set_inet_addr (& t , string , php_sock )) {
116116 memcpy (ss , & t , sizeof t );
117117 ss -> ss_family = AF_INET ;
118118 * ss_len = sizeof (t );
119- return 1 ;
119+ return true ;
120120 }
121121 }
122122#ifdef HAVE_IPV6
@@ -126,12 +126,12 @@ int php_set_inet46_addr(php_sockaddr_storage *ss, socklen_t *ss_len, zend_string
126126 memcpy (ss , & t , sizeof t );
127127 ss -> ss_family = AF_INET6 ;
128128 * ss_len = sizeof (t );
129- return 1 ;
129+ return true ;
130130 }
131131 }
132132#endif
133133 else {
134134 zend_value_error ("IP address used in the context of an unexpected type of socket" );
135135 }
136- return 0 ;
136+ return false ;
137137}
0 commit comments