@@ -1204,15 +1204,14 @@ PHP_FUNCTION(socket_connect)
12041204{
12051205 zval * resource_socket ;
12061206 php_socket * php_sock ;
1207- char * addr ;
1207+ zend_string * addr ;
12081208 int retval ;
1209- size_t addr_len ;
12101209 zend_long port ;
12111210 bool port_is_null = 1 ;
12121211
12131212 ZEND_PARSE_PARAMETERS_START (2 , 3 )
12141213 Z_PARAM_OBJECT_OF_CLASS (resource_socket , socket_ce )
1215- Z_PARAM_STRING (addr , addr_len )
1214+ Z_PARAM_STR (addr )
12161215 Z_PARAM_OPTIONAL
12171216 Z_PARAM_LONG_OR_NULL (port , port_is_null )
12181217 ZEND_PARSE_PARAMETERS_END ();
@@ -1265,15 +1264,15 @@ PHP_FUNCTION(socket_connect)
12651264 case AF_UNIX : {
12661265 struct sockaddr_un s_un = {0 };
12671266
1268- if (addr_len >= sizeof (s_un .sun_path )) {
1267+ if (ZSTR_LEN ( addr ) >= sizeof (s_un .sun_path )) {
12691268 zend_argument_value_error (2 , "must be less than %d" , sizeof (s_un .sun_path ));
12701269 RETURN_THROWS ();
12711270 }
12721271
12731272 s_un .sun_family = AF_UNIX ;
1274- memcpy (& s_un .sun_path , addr , addr_len );
1273+ memcpy (& s_un .sun_path , ZSTR_VAL ( addr ), ZSTR_LEN ( addr ) );
12751274 retval = connect (php_sock -> bsd_socket , (struct sockaddr * ) & s_un ,
1276- (socklen_t )(XtOffsetOf (struct sockaddr_un , sun_path ) + addr_len ));
1275+ (socklen_t )(XtOffsetOf (struct sockaddr_un , sun_path ) + ZSTR_LEN ( addr ) ));
12771276 break ;
12781277 }
12791278
@@ -1316,14 +1315,13 @@ PHP_FUNCTION(socket_bind)
13161315 php_sockaddr_storage sa_storage = {0 };
13171316 struct sockaddr * sock_type = (struct sockaddr * ) & sa_storage ;
13181317 php_socket * php_sock ;
1319- char * addr ;
1320- size_t addr_len ;
1318+ zend_string * addr ;
13211319 zend_long objint = 0 ;
13221320 zend_long retval = 0 ;
13231321
13241322 ZEND_PARSE_PARAMETERS_START (2 , 3 )
13251323 Z_PARAM_OBJECT_OF_CLASS (arg1 , socket_ce )
1326- Z_PARAM_STRING (addr , addr_len )
1324+ Z_PARAM_STR (addr )
13271325 Z_PARAM_OPTIONAL
13281326 Z_PARAM_LONG (objint )
13291327 ZEND_PARSE_PARAMETERS_END ();
@@ -1343,14 +1341,14 @@ PHP_FUNCTION(socket_bind)
13431341
13441342 sa -> sun_family = AF_UNIX ;
13451343
1346- if (addr_len >= sizeof (sa -> sun_path )) {
1344+ if (ZSTR_LEN ( addr ) >= sizeof (sa -> sun_path )) {
13471345 zend_argument_value_error (2 , "must be less than %d" , sizeof (sa -> sun_path ));
13481346 RETURN_THROWS ();
13491347 }
1350- memcpy (& sa -> sun_path , addr , addr_len );
1348+ memcpy (& sa -> sun_path , ZSTR_VAL ( addr ), ZSTR_LEN ( addr ) );
13511349
13521350 retval = bind (php_sock -> bsd_socket , (struct sockaddr * ) sa ,
1353- offsetof(struct sockaddr_un , sun_path ) + addr_len );
1351+ offsetof(struct sockaddr_un , sun_path ) + ZSTR_LEN ( addr ) );
13541352 break ;
13551353 }
13561354
@@ -1395,7 +1393,7 @@ PHP_FUNCTION(socket_bind)
13951393 RETURN_THROWS ();
13961394 }
13971395
1398- sa -> sll_ifindex = if_nametoindex (addr );
1396+ sa -> sll_ifindex = if_nametoindex (ZSTR_VAL ( addr ) );
13991397
14001398 retval = bind (php_sock -> bsd_socket , sock_type , sizeof (struct sockaddr_ll ));
14011399 break ;
@@ -1666,17 +1664,18 @@ PHP_FUNCTION(socket_sendto)
16661664 //struct sockaddr_ll sll;
16671665#endif
16681666 int retval ;
1669- size_t buf_len , addr_len ;
1667+ size_t buf_len ;
16701668 zend_long len , flags , port = 0 ;
16711669 bool port_is_null = 1 ;
1672- char * buf , * addr ;
1670+ char * buf ;
1671+ zend_string * addr ;
16731672
16741673 ZEND_PARSE_PARAMETERS_START (5 , 6 )
16751674 Z_PARAM_OBJECT_OF_CLASS (arg1 , socket_ce )
16761675 Z_PARAM_STRING (buf , buf_len )
16771676 Z_PARAM_LONG (len )
16781677 Z_PARAM_LONG (flags )
1679- Z_PARAM_STRING (addr , addr_len )
1678+ Z_PARAM_STR (addr )
16801679 Z_PARAM_OPTIONAL
16811680 Z_PARAM_LONG_OR_NULL (port , port_is_null )
16821681 ZEND_PARSE_PARAMETERS_END ();
@@ -1699,7 +1698,7 @@ PHP_FUNCTION(socket_sendto)
16991698 case AF_UNIX :
17001699 memset (& s_un , 0 , sizeof (s_un ));
17011700 s_un .sun_family = AF_UNIX ;
1702- snprintf (s_un .sun_path , sizeof (s_un .sun_path ), "%s" , addr );
1701+ snprintf (s_un .sun_path , sizeof (s_un .sun_path ), "%s" , ZSTR_VAL ( addr ) );
17031702
17041703 retval = sendto (php_sock -> bsd_socket , buf , ((size_t )len > buf_len ) ? buf_len : (size_t )len , flags , (struct sockaddr * ) & s_un , SUN_LEN (& s_un ));
17051704 break ;
0 commit comments