|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? 2019, PHP 7.2.22
+- Standard:
+ . Fixed bug #69100 (Bus error from stream_copy_to_stream (file -> SSL stream)
+ with invalid length). (Nikita)
+
01 Aug 2019, PHP 7.2.21
- Fileinfo:
--- /dev/null
+--TEST--
+Bug #69100: Bus error from stream_copy_to_stream (file -> SSL stream) with invalid length
+--FILE--
+<?php
+
+$fileIn = __DIR__ . '/bug69100_in.txt';
+$fileOut = __DIR__ . '/bug69100_out.txt';
+
+file_put_contents($fileIn, str_repeat('A', 64 * 1024));
+$fr = fopen($fileIn, 'rb');
+$fw = fopen($fileOut, 'w');
+
+var_dump(stream_copy_to_stream($fr, $fw, 32 * 1024));
+var_dump(stream_copy_to_stream($fr, $fw, 64 * 1024));
+
+fclose($fr);
+fclose($fw);
+unlink($fileIn);
+unlink($fileOut);
+
+?>
+--EXPECT--
+int(32768)
+int(32768)
return fd == -1 ? PHP_STREAM_OPTION_RETURN_ERR : PHP_STREAM_OPTION_RETURN_OK;
case PHP_STREAM_MMAP_MAP_RANGE:
- if(do_fstat(data, 1) != 0) {
+ 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;
- }
- if (range->length == 0 || range->length > data->sb.st_size) {
- range->length = data->sb.st_size;
- }
- if (range->offset >= data->sb.st_size) {
+ if (range->offset > data->sb.st_size) {
range->offset = data->sb.st_size;
- range->length = 0;
+ }
+ if (range->length == 0 ||
+ range->length > data->sb.st_size - range->offset) {
+ range->length = data->sb.st_size - range->offset;
}
switch (range->mode) {
case PHP_STREAM_MAP_MODE_READONLY: