diff options
| author | Anatol Belski <ab@php.net> | 2017-07-26 23:10:07 +0200 |
|---|---|---|
| committer | Anatol Belski <ab@php.net> | 2017-07-27 20:11:21 +0200 |
| commit | 49d9b3013fb2ee18b59694aa36036104a4bdd6f2 (patch) | |
| tree | 40da76daa5117b1ba623c3e6fcc5c4d44ce94777 /ext/standard | |
| parent | 00bed31d9f24ce46b461e911c06d7a8b6e2cf1c0 (diff) | |
| download | php-git-49d9b3013fb2ee18b59694aa36036104a4bdd6f2.tar.gz | |
Move cwd_state and path related routines to size_t
Having `int` there is no real profit in the size or speed, while unsigned
improves security and overall integration. ZPP supplied strings can
be then accepted directly and structs can be still handled with smaller
unsigned types for size reasons, which is safe. Yet some related places
are to go.
basic move tsrm_realpath_r to size_t
fix conditions and sync with affected places
touch ocurrences of php_sys_readlink usage
follow up on phar path handling
remove duplicated check
move zend_resolve_path and related pieces to size_t
touch yet resolve path related places
remove cast
missing pieces
missing piece
yet cleanups for php_sys_readlink for ssize_t
fix wrong return
Diffstat (limited to 'ext/standard')
| -rw-r--r-- | ext/standard/link.c | 2 | ||||
| -rw-r--r-- | ext/standard/link_win32.c | 5 | ||||
| -rw-r--r-- | ext/standard/streamsfuncs.c | 2 |
3 files changed, 5 insertions, 4 deletions
diff --git a/ext/standard/link.c b/ext/standard/link.c index c55e6f4b0a..7e0a6d3876 100644 --- a/ext/standard/link.c +++ b/ext/standard/link.c @@ -57,7 +57,7 @@ PHP_FUNCTION(readlink) char *link; size_t link_len; char buff[MAXPATHLEN]; - int ret; + ssize_t ret; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_PATH(link, link_len) diff --git a/ext/standard/link_win32.c b/ext/standard/link_win32.c index 53ce7fbb4d..406526128f 100644 --- a/ext/standard/link_win32.c +++ b/ext/standard/link_win32.c @@ -63,7 +63,7 @@ TODO: PHP_FUNCTION(readlink) { char *link; - size_t link_len; + ssize_t link_len; char target[MAXPATHLEN]; if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &link, &link_len) == FAILURE) { @@ -74,7 +74,8 @@ PHP_FUNCTION(readlink) RETURN_FALSE; } - if (php_sys_readlink(link, target, MAXPATHLEN) == -1) { + link_len = php_sys_readlink(link, target, MAXPATHLEN); + if (link_len == -1) { php_error_docref(NULL, E_WARNING, "readlink failed to read the symbolic link (%s), error %d)", link, GetLastError()); RETURN_FALSE; } diff --git a/ext/standard/streamsfuncs.c b/ext/standard/streamsfuncs.c index 475fb060be..979a64b913 100644 --- a/ext/standard/streamsfuncs.c +++ b/ext/standard/streamsfuncs.c @@ -1559,7 +1559,7 @@ PHP_FUNCTION(stream_resolve_include_path) Z_PARAM_PATH(filename, filename_len) ZEND_PARSE_PARAMETERS_END(); - resolved_path = zend_resolve_path(filename, (int)filename_len); + resolved_path = zend_resolve_path(filename, filename_len); if (resolved_path) { RETURN_STR(resolved_path); |
