1--TEST-- 2Bug #60106 (stream_socket_server with abstract unix socket paths) 3--SKIPIF-- 4<?php 5if (PHP_OS != "Linux") die("skip Only for Linux systems"); 6?> 7--FILE-- 8<?php 9error_reporting(E_ALL | E_NOTICE); 10 11/* This figures out the max length for normal sockets */ 12$socket_file = "/tmp/" . str_repeat("a", 512); 13function get_truncated_socket_filename($errno, $errmsg, $file, $line) { 14 global $socket_file, $max_normal_length; 15 echo $errmsg, "\n"; 16 preg_match("#maximum allowed length of (\d+) bytes#", $errmsg, $matches); 17 $max_normal_length = intval($matches[1]); 18 $socket_file = substr($socket_file, 0, $max_normal_length); 19} 20set_error_handler("get_truncated_socket_filename", E_NOTICE); 21 22stream_socket_server("unix://" . $socket_file); 23unlink($socket_file); 24 25/* No we create an abstract one, prefixed with \0 so this should now work */ 26$abstract_socket = "\0" . $socket_file; 27stream_socket_server("unix://" . $abstract_socket); 28 29$old_max_length = $max_normal_length; 30 31/* And now one longer, which should fail again */ 32$abstract_socket_long = "\0" . $abstract_socket . 'X'; 33stream_socket_server("unix://" . $abstract_socket_long); 34 35echo "Allowed length is now one more: ", $max_normal_length == $old_max_length + 1 ? "yes" : "no", "\n"; 36?> 37--EXPECTF-- 38stream_socket_server(): socket path exceeded the maximum allowed length of %d bytes and was truncated 39stream_socket_server(): socket path exceeded the maximum allowed length of %d bytes and was truncated 40Allowed length is now one more: yes 41