]> granicus.if.org Git - php/commitdiff
Fix #80048: Bug #69100 has not been fixed for Windows
authorChristoph M. Becker <cmbecker69@gmx.de>
Thu, 3 Sep 2020 12:27:45 +0000 (14:27 +0200)
committerChristoph M. Becker <cmbecker69@gmx.de>
Thu, 3 Sep 2020 13:43:19 +0000 (15:43 +0200)
We fix the erroneous length calculation on Windows, too.

Closes GH-6067.

NEWS
main/streams/plain_wrapper.c

diff --git a/NEWS b/NEWS
index 8a2432c2df8a16eebdd504147a9df20af2a16b81..0800e83e0f9346579f89c816b64b0fb40c0c530d 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,9 @@ PHP                                                                        NEWS
 |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
 ?? ??? ????, PHP 7.3.23
 
+- Core:
+  . Fixed bug #80048 (Bug #69100 has not been fixed for Windows). (cmb)
+
 - Calendar:
   . Fixed bug #80007 (Potential type confusion in unixtojd() parameter parsing).
     (Andy Postnikov)
index c975997981304ad5a8abef365135e1bead3b5d18..2b819128576261fdb1b02a4300b5678d973eb3f0 100644 (file)
@@ -786,15 +786,11 @@ static int php_stdiop_set_option(php_stream *stream, int option, int value, void
                                                }
 
                                                size = GetFileSize(hfile, NULL);
-                                               if (range->length == 0 && range->offset > 0 && range->offset < size) {
-                                                       range->length = size - range->offset;
-                                               }
-                                               if (range->length == 0 || range->length > size) {
-                                                       range->length = size;
-                                               }
-                                               if (range->offset >= size) {
+                                               if (range->offset > size) {
                                                        range->offset = size;
-                                                       range->length = 0;
+                                               }
+                                               if (range->length == 0 || range->length > size - range->offset) {
+                                                       range->length = size - range->offset;
                                                }
 
                                                /* figure out how big a chunk to map to be able to view the part that we need */