Raw sockets using AF_INET/6 don't allow lack of port for ICMP protocol
- Dominant language
- C++
- Stars
- 18.7k
- Forks
- 3.1k
- Avg merge
- 1h 47m
- Merged PRs (30d)
- 2
Description
This is a PHP5 incompatibility.
When using raw sockets with ICMP, HHVM requires a port which results in a write failure, whereas PHP5 accepts a null value. This can be worked around by supplying any port.
Example code:
``` php
1, 'usec' => 0));
socket_connect($socket, 'localhost', null);
socket_send($socket, $payload, strlen($payload), 0);
$recv = socket_read($socket, 255);
if ($recv === false) {
echo socket_strerror(socket_last_error($socket)) . PHP_EOL;
} else {
var_dump($recv);
}
socket_close($socket);
}
pingTestCase();
```
Example run in Zend engine:
``` bash
Mortisha:tmp root# php -v
PHP 5.5.27 (cli) (built: Jul 23 2015 00:21:59)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2015 Zend Technologies
Mortisha:tmp root#
Mortisha:tmp root#
Mortisha:tmp root#
Mortisha:tmp root# php ping.php
string(36) "Er�@�KPingHost"
Mortisha:tmp root#
```
Example run in HHVM:
``` bash
root:/tmp# hhvm --version
HipHop VM 3.9.1 (rel)
Compiler: tags/HHVM-3.9.1-0-g0f72cfc2f0a01fdfeb72fbcfeb247b72998a66db
Repo schema: 6416960c150a4a4726fda74b659105ded8819d9c
root:/tmp#
root:/tmp#
root:/tmp#
root:/tmp# hhvm ping.php
Warning: Socket of type AF_INET/6 requires 3 arguments in /tmp/ping.php on line 9
Warning: unable to write to socket [89]: Destination address required in /tmp/ping.php on line 10
Resource temporarily unavailable
root:/tmp#
```
Contributor guide
Assessment
This issue has not been assessed yet.