diff options
author | Dmitry Stogov <dmitry@php.net> | 2007-04-18 14:23:06 +0000 |
---|---|---|
committer | Dmitry Stogov <dmitry@php.net> | 2007-04-18 14:23:06 +0000 |
commit | 41d27878dee99910f7a0377a0b3a2ae0e5d456c3 (patch) | |
tree | 1e488b8ce56fff45df5c36963f486720ae455b17 /main/streams/plain_wrapper.c | |
parent | 02ee91dbb4b424adb6912076a0dd3e7b9a271f12 (diff) | |
download | php-git-41d27878dee99910f7a0377a0b3a2ae0e5d456c3.tar.gz |
Fixed crash on win32 in case of negative size
Diffstat (limited to 'main/streams/plain_wrapper.c')
-rw-r--r-- | main/streams/plain_wrapper.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/main/streams/plain_wrapper.c b/main/streams/plain_wrapper.c index 877b605a7d..cf5858aac0 100644 --- a/main/streams/plain_wrapper.c +++ b/main/streams/plain_wrapper.c @@ -773,8 +773,13 @@ static int php_stdiop_set_option(php_stream *stream, int option, int value, void case PHP_STREAM_TRUNCATE_SUPPORTED: return fd == -1 ? PHP_STREAM_OPTION_RETURN_ERR : PHP_STREAM_OPTION_RETURN_OK; - case PHP_STREAM_TRUNCATE_SET_SIZE: - return ftruncate(fd, *(ptrdiff_t*)ptrparam) == 0 ? PHP_STREAM_OPTION_RETURN_OK : PHP_STREAM_OPTION_RETURN_ERR; + case PHP_STREAM_TRUNCATE_SET_SIZE: { + ptrdiff_t new_size = *(ptrdiff_t*)ptrparam; + if (new_size < 0) { + return PHP_STREAM_OPTION_RETURN_ERR; + } + return ftruncate(fd, new_size) == 0 ? PHP_STREAM_OPTION_RETURN_OK : PHP_STREAM_OPTION_RETURN_ERR; + } } default: |