Fixed bug #60106 (stream_socket_server silently truncates long unix socket paths)

This commit is contained in:
Ilia Alshanetsky 2012-03-03 20:36:14 +00:00
parent 9b9f05fd6e
commit 5525d80982
3 changed files with 16 additions and 0 deletions

1
NEWS
View File

@ -45,6 +45,7 @@ PHP NEWS
- Standard:
. Fixed memory leak in substr_replace. (Pierrick)
. Make max_file_uploads ini directive settable outside of php.ini (Rasmus)
. Fixed bug #60106 (stream_socket_server silently truncates long unix socket paths). (Ilia)
- XMLRPC:
. Fixed bug #61097 (Memory leak in xmlrpc functions copying zvals). (Nikita Popov)

View File

@ -0,0 +1,14 @@
--TEST--
Bug#60106 (stream_socket_server silently truncates long unix socket paths)
--FILE--
<?php
error_reporting(E_ALL | E_NOTICE);
stream_socket_server("unix:///tmp/" . str_repeat("a", 4096));
?>
===DONE===
--EXPECTF--
Notice: stream_socket_server(): socket path exceeded the maximum allowed length of %d bytes and was truncated in %s on line %d
Warning: stream_socket_server(): unable to connect to unix:///tmp/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa in %s on line %d
===DONE===

View File

@ -510,6 +510,7 @@ static inline int parse_unix_address(php_stream_xport_param *xparam, struct sock
* BUT, to get into this branch of code, the name is too long,
* so we don't care. */
xparam->inputs.namelen = sizeof(unix_addr->sun_path) - 1;
php_error_docref(NULL TSRMLS_CC, E_NOTICE, "socket path exceeded the maximum allowed length of %ld bytes and was truncated", sizeof(unix_addr->sun_path));
}
memcpy(unix_addr->sun_path, xparam->inputs.name, xparam->inputs.namelen);