]> granicus.if.org Git - php/commitdiff
do_fstat changes
authorJoshua Rogers <git@internot.info>
Tue, 27 Jan 2015 13:18:17 +0000 (00:18 +1100)
committerJoshua Rogers <git@internot.info>
Sun, 1 Feb 2015 07:47:09 +0000 (18:47 +1100)
Check return values of 'do_fstat' function in all places.

main/streams/plain_wrapper.c

index 284ba05ea8353114ff1a93251909397962a40db2..652438efc9eb4d4e3b10dc6787b54e581b3edf4f 100644 (file)
@@ -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;
                                                }