com php-src: cleanup casts: main/php_open_temporary_file .c main/streams/plain_wrapper.c win32/winutil.c win32/winutil.h

From: Date: Sun, 09 Jul 2017 13:31:05 +0000
Subject: com php-src: cleanup casts: main/php_open_temporary_file .c main/streams/plain_wrapper.c win32/winutil.c win32/winutil.h
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-98474@lists.php.net to get a copy of this message
Commit: 84079f4a1ef4c3c10ef81da33e75949ca8ab8347 Author: Anatol Belski <ab@php.net> Sun, 9 Jul 2017 15:31:05 +0200 Parents: e403acc74b63d051ce8fd62f081c1302a720a590 Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=84079f4a1ef4c3c10ef81da33e75949ca8ab8347 Log: cleanup casts Changed paths: M main/php_open_temporary_file.c M main/streams/plain_wrapper.c M win32/winutil.c M win32/winutil.h Diff: diff --git a/main/php_open_temporary_file.c b/main/php_open_temporary_file.c index 50107f6..f230388 100644 --- a/main/php_open_temporary_file.c +++ b/main/php_open_temporary_file.c @@ -114,7 +114,7 @@ static int php_do_open_temporary_file(const char *path, const char *pfx, zend_st } #ifdef PHP_WIN32 - if (!php_win32_check_trailing_space(pfx, (const int)strlen(pfx))) { + if (!php_win32_check_trailing_space(pfx, strlen(pfx))) { SetLastError(ERROR_INVALID_NAME); return -1; } diff --git a/main/streams/plain_wrapper.c b/main/streams/plain_wrapper.c index 537021a..7e18941 100644 --- a/main/streams/plain_wrapper.c +++ b/main/streams/plain_wrapper.c @@ -1139,11 +1139,11 @@ static int php_plain_files_rename(php_stream_wrapper *wrapper, const char *url_f } #ifdef PHP_WIN32 - if (!php_win32_check_trailing_space(url_from, (int)strlen(url_from))) { + if (!php_win32_check_trailing_space(url_from, strlen(url_from))) { php_win32_docref2_from_error(ERROR_INVALID_NAME, url_from, url_to); return 0; } - if (!php_win32_check_trailing_space(url_to, (int)strlen(url_to))) { + if (!php_win32_check_trailing_space(url_to, strlen(url_to))) { php_win32_docref2_from_error(ERROR_INVALID_NAME, url_from, url_to); return 0; } @@ -1311,7 +1311,7 @@ static int php_plain_files_rmdir(php_stream_wrapper *wrapper, const char *url, i } #ifdef PHP_WIN32 - if (!php_win32_check_trailing_space(url, (int)strlen(url))) { + if (!php_win32_check_trailing_space(url, strlen(url))) { php_error_docref1(NULL, url, E_WARNING, "%s", strerror(ENOENT)); return 0; } @@ -1337,12 +1337,9 @@ static int php_plain_files_metadata(php_stream_wrapper *wrapper, const char *url #endif mode_t mode; int ret = 0; -#ifdef PHP_WIN32 - int url_len = (int)strlen(url); -#endif #ifdef PHP_WIN32 - if (!php_win32_check_trailing_space(url, url_len)) { + if (!php_win32_check_trailing_space(url, strlen(url))) { php_error_docref1(NULL, url, E_WARNING, "%s", strerror(ENOENT)); return 0; } diff --git a/win32/winutil.c b/win32/winutil.c index 2852a19..34dda95 100644 --- a/win32/winutil.c +++ b/win32/winutil.c @@ -36,9 +36,9 @@ PHP_WINUTIL_API char *php_win32_error_to_msg(HRESULT error) return (buf ? (char *) buf : ""); }/*}}}*/ -int php_win32_check_trailing_space(const char * path, const int path_len) +int php_win32_check_trailing_space(const char * path, const size_t path_len) {/*{{{*/ - if (path_len < 1) { + if (path_len > MAXPATHLEN - 1) { return 1; } if (path) { diff --git a/win32/winutil.h b/win32/winutil.h index d4d3700..a08cdbe 100644 --- a/win32/winutil.h +++ b/win32/winutil.h @@ -28,7 +28,7 @@ PHP_WINUTIL_API char *php_win32_error_to_msg(HRESULT error); #define php_win_err() php_win32_error_to_msg(GetLastError()) -int php_win32_check_trailing_space(const char * path, const int path_len); +int php_win32_check_trailing_space(const char * path, const size_t path_len); PHP_WINUTIL_API int php_win32_get_random_bytes(unsigned char *buf, size_t size); #ifdef PHP_EXPORTS BOOL php_win32_init_random_bytes(void);

« previous php.cvs (#98474) next »