com php-src: do_fstat changes: main/streams/plain_wra pper.c
| From: | Stanislav Malyshev | Date: | Sun, 01 Feb 2015 07:47:09 +0000 |
| Subject: | com php-src: do_fstat changes: main/streams/plain_wra pper.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-84546@lists.php.net to get a copy of this message | ||
Commit: f8bf646fc41c26b010c2db7d36a3c430d5911324
Author: Joshua Rogers <git@internot.info> Wed, 28 Jan 2015 00:18:17 +1100
Parents: dfe6aea9cab6df556049ec2c9867d97a97e0fe09
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=f8bf646fc41c26b010c2db7d36a3c430d5911324
Log:
do_fstat changes
Check return values of 'do_fstat' function in all places.
Changed paths:
M main/streams/plain_wrapper.c
Diff:
diff --git a/main/streams/plain_wrapper.c b/main/streams/plain_wrapper.c
index 284ba05..652438e 100644
--- a/main/streams/plain_wrapper.c
+++ b/main/streams/plain_wrapper.c
@@ -577,9 +577,10 @@ static int php_stdiop_stat(php_stream *stream, php_stream_statbuf *ssb)
php_stdio_stream_data *data = (php_stdio_stream_data*) stream->abstract;
assert(data != NULL);
+ if((ret = do_fstat(data, 1)) == 0) {
+ memcpy(&ssb->sb, &data->sb, sizeof(ssb->sb));
+ }
- ret = do_fstat(data, 1);
- memcpy(&ssb->sb, &data->sb, sizeof(ssb->sb));
return ret;
}
@@ -669,7 +670,9 @@ static int php_stdiop_set_option(php_stream *stream, int option, int value, void
return fd == -1 ? PHP_STREAM_OPTION_RETURN_ERR : PHP_STREAM_OPTION_RETURN_OK;
case PHP_STREAM_MMAP_MAP_RANGE:
- do_fstat(data, 1);
+ if(do_fstat(data, 1) != 0) {
+ return PHP_STREAM_OPTION_RETURN_ERR;
+ }
if (range->length == 0 && range->offset > 0 && range->offset <
data->sb.st_size) {
range->length = data->sb.st_size - range->offset;
}