com php-src: fixes to plain stream wrapper: main/streams/plain _wrapper.c win32/winutil.c win32/winutil.h
| From: | Anatol Belski | Date: | Wed, 16 Oct 2013 09:32:21 +0000 |
| Subject: | com php-src: fixes to plain stream wrapper: main/streams/plain _wrapper.c win32/winutil.c win32/winutil.h | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-73508@lists.php.net to get a copy of this message | ||
Commit: 9f294bf2827e28c8fe5dd5a326a5b7c072bf2194
Author: Anatol Belski <ab@php.net> Wed, 17 Jul 2013 05:50:33 -0700
Parents: 5748286990c8371c84ec63caf5bd3e89bb6a7530
Branches: str_size_and_int64
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=9f294bf2827e28c8fe5dd5a326a5b7c072bf2194
Log:
fixes to plain stream wrapper
Changed paths:
M main/streams/plain_wrapper.c
M win32/winutil.c
M win32/winutil.h
Diff:
diff --git a/main/streams/plain_wrapper.c b/main/streams/plain_wrapper.c
index 949b827..63d1772 100644
--- a/main/streams/plain_wrapper.c
+++ b/main/streams/plain_wrapper.c
@@ -53,6 +53,12 @@ extern int php_get_uid_by_name(const char *name, uid_t *uid TSRMLS_DC);
extern int php_get_gid_by_name(const char *name, gid_t *gid TSRMLS_DC);
#endif
+#if defined(PHP_WIN32)
+# define PLAIN_WRAP_BUF_SIZE(st) (((st) > UINT_MAX) ? UINT_MAX : (unsigned int)(st))
+#else
+# define PLAIN_WRAP_BUF_SIZE(st) (st)
+#endif
+
/* parse standard "fopen" modes into open() flags */
PHPAPI int php_stream_parse_fopen_modes(const char *mode, int *open_flags)
{
@@ -322,7 +328,7 @@ static size_t php_stdiop_write(php_stream *stream, const char *buf, size_t count
assert(data != NULL);
if (data->fd >= 0) {
- int bytes_written = write(data->fd, buf, count);
+ ssize_t bytes_written = write(data->fd, buf, PLAIN_WRAP_BUF_SIZE(count));
if (bytes_written < 0) return 0;
return (size_t) bytes_written;
} else {
@@ -346,13 +352,13 @@ static size_t php_stdiop_read(php_stream *stream, char *buf, size_t count
TSRMLS
assert(data != NULL);
if (data->fd >= 0) {
- ret = read(data->fd, buf, count);
+ ret = read(data->fd, buf, PLAIN_WRAP_BUF_SIZE(count));
if (ret == (size_t)-1 && errno == EINTR) {
/* Read was interrupted, retry once,
If read still fails, giveup with feof==0
so script can retry if desired */
- ret = read(data->fd, buf, count);
+ ret = read(data->fd, buf, PLAIN_WRAP_BUF_SIZE(count));
}
stream->eof = (ret == 0 || (ret == (size_t)-1 && errno != EWOULDBLOCK && errno
!= EINTR && errno != EBADF));
@@ -1164,7 +1170,7 @@ static int php_plain_files_mkdir(php_stream_wrapper *wrapper, const char *dir,
i
/* we look for directory separator from the end of string, thus hopefuly reducing our work load
*/
char *e;
struct stat sb;
- int dir_len = strlen(dir);
+ zend_str_size_int dir_len = strlen(dir);
int offset = 0;
char buf[MAXPATHLEN];
@@ -1238,7 +1244,7 @@ static int php_plain_files_mkdir(php_stream_wrapper *wrapper, const char *dir,
i
static int php_plain_files_rmdir(php_stream_wrapper *wrapper, const char *url, int options,
php_stream_context *context TSRMLS_DC)
{
#if PHP_WIN32
- int url_len = strlen(url);
+ zend_str_size_int url_len = strlen(url);
#endif
if (php_check_open_basedir(url TSRMLS_CC)) {
return 0;
@@ -1273,7 +1279,7 @@ static int php_plain_files_metadata(php_stream_wrapper *wrapper, const char
*url
mode_t mode;
int ret = 0;
#if PHP_WIN32
- int url_len = strlen(url);
+ zend_str_size_int url_len = strlen(url);
#endif
#if PHP_WIN32
@@ -1379,9 +1385,9 @@ PHPAPI php_stream *_php_stream_fopen_with_path(const char *filename, const
char
const char *exec_fname;
char trypath[MAXPATHLEN];
php_stream *stream;
- int path_length;
- int filename_length;
- int exec_fname_length;
+ zend_str_size_int path_length;
+ zend_str_size_int filename_length;
+ zend_str_size_int exec_fname_length;
if (opened_path) {
*opened_path = NULL;
diff --git a/win32/winutil.c b/win32/winutil.c
index 4afc28f..1f467c9 100644
--- a/win32/winutil.c
+++ b/win32/winutil.c
@@ -34,7 +34,7 @@ PHPAPI char *php_win32_error_to_msg(int 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 zend_str_size_int path_len) {
if (path_len < 1) {
return 1;
}
diff --git a/win32/winutil.h b/win32/winutil.h
index 8cf07ec..3292174 100644
--- a/win32/winutil.h
+++ b/win32/winutil.h
@@ -19,7 +19,7 @@
PHPAPI char *php_win32_error_to_msg(int 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 zend_str_size_int path_len);
PHPAPI php_win32_get_random_bytes(unsigned char *buf, size_t size);
#ifdef ZTS