|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #35490 socket_sendto() unable to handle IPv6 addresses
Submitted: 2005-11-30 14:55 UTC Modified: 2005-12-01 15:02 UTC
From: Xavier dot Redon at polytech-lille dot fr Assigned:
Status: Closed Package: Sockets related
PHP Version: 5.1.1 OS: Linux 2.6
Private report: No CVE-ID:
 [2005-11-30 14:55 UTC] Xavier dot Redon at polytech-lille dot fr
When executing the script below an error occurs.
A trace with strace show that the struct sockaddr of the system call sendto is uninitialized (or badly initialized) :

sendto(3, "Test Message", 12, 0, {sa_family=0x45a0 /* AF_??? */, sa_data="<\10\20\0\0\0\20\0\0\0\250\376\343\277"}, 16) = -1 EINVAL (Invalid argument)

Reproduce code:
$sh = socket_create(AF_INET6,SOCK_DGRAM,0);
if (socket_bind($sh, '::1', 4242)) {
    echo "Socket ok\n";
$buf = 'Test Message';
$len = strlen($buf);
if (socket_sendto($sh, $buf, $len, 0x00, '::1', 4000) !== FALSE) {
    echo "Message sent\n";

Expected result:
an IPv6 UDP datagram should be sent to the IPv6 loopback address.

Actual result:
Warning: socket_sendto(): unable to write to socket [22]: Invalid argument in /tmp/toto.php on line 12


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2005-12-01 15:02 UTC]
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
Thank you for the report, and for helping us make PHP better.

PHP Copyright © 2001-2015 The PHP Group
All rights reserved.
Last updated: Wed Nov 25 16:01:37 2015 UTC