|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #65808 the socket_connect() won't work with IPv6 address
Submitted: 2013-10-02 10:11 UTC Modified: 2013-10-02 12:32 UTC
From: wzis at hotmail dot com Assigned: mike
Status: Closed Package: Sockets related
PHP Version: 5.5.4 OS: Linux
Private report: No CVE-ID:
 [2013-10-02 10:11 UTC] wzis at hotmail dot com
No matter give fe80::a00:27ff:fe3d:af20 or fe80::a00:27ff:fe3d:af20%eth0 as the address, the socket_connect will just fail.
From strace and the PHP source code, what I found is the sin6_scope_id always equals to 0, while with telnet when passed in fe80::a00:27ff:fe3d:af20%eth0, from strace, we got sin6_scope_id=if_nametoindex("eth0"). So the socket_connect code needs be changed for proper IPv6 support.

Test script:
  $sock=socket_create(AF_INET6, SOCK_STREAM, 0);
  if(socket_connect($sock, $argv[1], $argv[2]))
    echo "Connected to ".$argv[1]." port ".$argv[2];

Expected result:
If you run the script with
  ./phpscript 2606:4100:3880:1250::100 80
You should see "Connected to 2606:4100:3880:1250::100 port 80"

Actual result:
PHP Warning:  socket_connect(): unable to connect [22]: Invalid argument in phpscript on line 4.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2013-10-02 12:32 UTC]
-Status: Open +Status: Verified -Assigned To: +Assigned To: mike
 [2013-10-02 13:56 UTC]
Automatic comment on behalf of mike
Log: fix bug #65808 	the socket_connect() won't work with IPv6 address
 [2013-10-02 13:56 UTC]
-Status: Verified +Status: Closed
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Fri Apr 18 23:01:58 2014 UTC