]> granicus.if.org Git - php/commitdiff
Fix #80654: file_get_contents() maxlen fails above (2**31)-1 bytes
authorChristoph M. Becker <cmbecker69@gmx.de>
Thu, 28 Jan 2021 16:00:16 +0000 (17:00 +0100)
committerChristoph M. Becker <cmbecker69@gmx.de>
Mon, 1 Feb 2021 11:57:40 +0000 (12:57 +0100)
We remove the arbitrary restriction to `INT_MAX`; it is superfluous on
32bit systems where `ZEND_LONG_MAX == INT_MAX` anyway, and not useful
on 64bit systems, where larger files should be readable, if the
`memory_limit` is large enough.

Closes GH-6648.

NEWS
ext/standard/file.c
ext/standard/streamsfuncs.c

diff --git a/NEWS b/NEWS
index 3349f4acda39934ee44ec7fac76756af32f4ba9e..9ca7f5624b021ea664f344e91a408642d543bfed 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -10,6 +10,10 @@ PHP                                                                        NEWS
     semicolon) (cmb)
   . Fixed bug #70091 (Phar does not mark UTF-8 filenames in ZIP archives). (cmb)
 
+- Standard:
+  . Fixed bug #80654 (file_get_contents() maxlen fails above (2**31)-1 bytes).
+    (cmb)
+
 - Zip:
   . Fixed bug #80648 (Fix for bug 79296 should be based on runtime version).
     (cmb, Remi)
index 12c21c93cd4180fbedbf95ad11bf7293eb717b47..3bd3421603f78c0818e1acffe7f42e8bff870839 100644 (file)
@@ -564,10 +564,6 @@ PHP_FUNCTION(file_get_contents)
                RETURN_FALSE;
        }
 
-       if (maxlen > INT_MAX) {
-               php_error_docref(NULL, E_WARNING, "maxlen truncated from " ZEND_LONG_FMT " to %d bytes", maxlen, INT_MAX);
-               maxlen = INT_MAX;
-       }
        if ((contents = php_stream_copy_to_mem(stream, maxlen, 0)) != NULL) {
                RETVAL_STR(contents);
        } else {
index 68ad6483e81fd28098231fba0caff70403240b2a..907feba7417a126847deaab439a7c3369e1cecd9 100644 (file)
@@ -456,10 +456,6 @@ PHP_FUNCTION(stream_get_contents)
                }
        }
 
-       if (maxlen > INT_MAX) {
-               php_error_docref(NULL, E_WARNING, "maxlen truncated from " ZEND_LONG_FMT " to %d bytes", maxlen, INT_MAX);
-               maxlen = INT_MAX;
-       }
        if ((contents = php_stream_copy_to_mem(stream, maxlen, 0))) {
                RETURN_STR(contents);
        } else {