summaryrefslogtreecommitdiff
path: root/main/network.c
diff options
context:
space:
mode:
authorIlia Alshanetsky <iliaa@php.net>2009-05-04 13:09:15 +0000
committerIlia Alshanetsky <iliaa@php.net>2009-05-04 13:09:15 +0000
commit8c9195e48de318d06d381951aa618413572a58c0 (patch)
tree8b4c60c5a6fe2cdc4910df1c2df69223b5cf9ed0 /main/network.c
parentc3bd64a5be69d4d028efecf12fc309e49043403f (diff)
downloadphp-git-8c9195e48de318d06d381951aa618413572a58c0.tar.gz
Fixed bug #48131 (Don't try to bind ipv4 addresses to ipv6 ips via bindto)
Diffstat (limited to 'main/network.c')
-rw-r--r--main/network.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/main/network.c b/main/network.c
index e5d2f595bc..4a2a6db74c 100644
--- a/main/network.c
+++ b/main/network.c
@@ -792,9 +792,14 @@ php_socket_t php_network_connect_socket_to_host(const char *host, unsigned short
switch (sa->sa_family) {
#if HAVE_GETADDRINFO && HAVE_IPV6
case AF_INET6:
- ((struct sockaddr_in6 *)sa)->sin6_family = sa->sa_family;
- ((struct sockaddr_in6 *)sa)->sin6_port = htons(port);
- socklen = sizeof(struct sockaddr_in6);
+ if (strstr(bindto, ':')) {
+ ((struct sockaddr_in6 *)sa)->sin6_family = sa->sa_family;
+ ((struct sockaddr_in6 *)sa)->sin6_port = htons(port);
+ socklen = sizeof(struct sockaddr_in6);
+ } else {
+ socklen = 0;
+ sa = NULL;
+ }
break;
#endif
case AF_INET:
@@ -814,7 +819,7 @@ php_socket_t php_network_connect_socket_to_host(const char *host, unsigned short
if (bindto) {
struct sockaddr *local_address = NULL;
int local_address_len = 0;
-
+
if (sa->sa_family == AF_INET) {
struct sockaddr_in *in4 = emalloc(sizeof(struct sockaddr_in));