diff options
author | Michael Wallner <mike@php.net> | 2013-10-02 15:55:38 +0200 |
---|---|---|
committer | Michael Wallner <mike@php.net> | 2013-10-02 15:55:38 +0200 |
commit | 2ba39268151549f03140ec3d260cf9489336ec93 (patch) | |
tree | 8e17ec062b521a83525ee9d39304fdfe94ef72aa /ext/sockets/sockaddr_conv.c | |
parent | 60e38b3243577abc80ce6bbcfb0b4125b08acb85 (diff) | |
parent | 9209c19f8f7eef807cb457b32d3ab517ff8dc178 (diff) | |
download | php-git-2ba39268151549f03140ec3d260cf9489336ec93.tar.gz |
Merge branch 'PHP-5.4' into PHP-5.5
* PHP-5.4:
fix bug #65808 the socket_connect() won't work with IPv6 address
5.4.22-dev now
Conflicts:
configure.in
ext/sockets/sockets.c
main/php_version.h
Diffstat (limited to 'ext/sockets/sockaddr_conv.c')
-rw-r--r-- | ext/sockets/sockaddr_conv.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/ext/sockets/sockaddr_conv.c b/ext/sockets/sockaddr_conv.c index a40b6b4936..64523c3191 100644 --- a/ext/sockets/sockaddr_conv.c +++ b/ext/sockets/sockaddr_conv.c @@ -18,6 +18,7 @@ int php_set_inet6_addr(struct sockaddr_in6 *sin6, char *string, php_socket *php_ struct addrinfo hints; struct addrinfo *addrinfo = NULL; #endif + char *scope = strchr(string, '%'); if (inet_pton(AF_INET6, string, &tmp)) { memcpy(&(sin6->sin6_addr.s6_addr), &(tmp.s6_addr), sizeof(struct in6_addr)); @@ -53,6 +54,22 @@ int php_set_inet6_addr(struct sockaddr_in6 *sin6, char *string, php_socket *php_ } + if (scope++) { + long lval = 0; + double dval = 0; + unsigned scope_id = 0; + + if (IS_LONG == is_numeric_string(scope, strlen(scope), &lval, &dval, 0)) { + if (lval > 0 && lval <= UINT_MAX) { + scope_id = lval; + } + } else { + php_string_to_if_index(scope, &scope_id TSRMLS_CC); + } + + sin6->sin6_scope_id = scope_id; + } + return 1; } /* }}} */ |