php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login

Patch restore-old-position for Filesystem function related Bug #77081

Patch version 2018-10-29 22:31 UTC

Return to Bug #77081 | Download this patch
Patch Revisions:

Developer: cmb@php.net

 main/streams/plain_wrapper.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/main/streams/plain_wrapper.c b/main/streams/plain_wrapper.c
index fdfc7b4f63..1bf5ac2a52 100644
--- a/main/streams/plain_wrapper.c
+++ b/main/streams/plain_wrapper.c
@@ -858,12 +858,14 @@ static int php_stdiop_set_option(php_stream *stream, int option, int value, void
 						return PHP_STREAM_OPTION_RETURN_ERR;
 					}
 
+					LARGE_INTEGER sz;
+					sz.HighPart = 0;
+					sz.LowPart = 0;
 					LARGE_INTEGER old_sz;
-					if (!GetFileSizeEx(h, &old_sz)) {
+					if (!SetFilePointerEx(h, sz, &old_sz, FILE_CURRENT)) {
 						return PHP_STREAM_OPTION_RETURN_ERR;
 					}
 
-					LARGE_INTEGER sz;
 #if defined(_WIN64)
 					sz.HighPart = (new_size >> 32);
 					sz.LowPart = (new_size & 0xffffffff);
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Thu Nov 26 23:01:25 2020 UTC