php.net |  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: None
 [2005-11-30 14:55 UTC] Xavier dot Redon at polytech-lille dot fr
Description:
------------
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";
}
socket_close($sh);
?>


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



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-12-01 15:02 UTC] tony2001@php.net
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
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 05:01:29 2024 UTC