Merge branch 'PHP-8.2' into PHP-8.3

This commit is contained in:
Jakub Zelenka 2023-10-22 13:27:45 +01:00
commit 82e9ba2bb3
No known key found for this signature in database
GPG Key ID: 1C0779DC5C0A9DE4
4 changed files with 75 additions and 1 deletions

4
NEWS
View File

@ -44,6 +44,10 @@ PHP NEWS
. Fix segfault and assertion failure with refcounted props and arrays.
(nielsdos)
- Streams:
. Fixed bug #75708 (getimagesize with "&$imageinfo" fails on StreamWrappers).
(Jakub Zelenka)
- XSL:
. Add missing module dependency. (nielsdos)

View File

@ -394,6 +394,20 @@ static int php_skip_variable(php_stream * stream)
}
/* }}} */
static size_t php_read_stream_all_chunks(php_stream *stream, char *buffer, size_t length)
{
size_t read_total = 0;
do {
ssize_t read_now = php_stream_read(stream, buffer, length - read_total);
read_total += read_now;
if (read_now < stream->chunk_size && read_total != length) {
return 0;
}
} while (read_total < length);
return read_total;
}
/* {{{ php_read_APP */
static int php_read_APP(php_stream * stream, unsigned int marker, zval *info)
{
@ -410,7 +424,7 @@ static int php_read_APP(php_stream * stream, unsigned int marker, zval *info)
buffer = emalloc(length);
if (php_stream_read(stream, buffer, (size_t) length) != length) {
if (php_read_stream_all_chunks(stream, buffer, length) != length) {
efree(buffer);
return 0;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

View File

@ -0,0 +1,56 @@
--TEST--
Bug #75708 (getimagesize with "&$imageinfo" fails on StreamWrappers)
--FILE--
<?php
class FSStreamWrapper {
function stream_open($file, $mode) {
$this->handle = fopen(str_replace('fs://', __DIR__ . '/', $file), $mode);
return true;
}
function stream_read($count) {
return fread($this->handle, $count);
}
function stream_eof() {
return feof($this->handle);
}
function stream_seek($offset, $whence) {
return fseek($this->handle, $offset, $whence) === 0;
}
function stream_stat() {
return fstat($this->handle);
}
function url_stat($file) {
return stat(str_replace('fs://', '', $file));
}
function stream_tell() {
return ftell($this->handle);
}
function stream_close() {
fclose($this->handle);
}
}
stream_register_wrapper('fs', 'FSStreamWrapper');
var_dump(getimagesize('fs://bug75708.jpg', $info));
?>
--EXPECT--
array(7) {
[0]=>
int(10)
[1]=>
int(10)
[2]=>
int(2)
[3]=>
string(22) "width="10" height="10""
["bits"]=>
int(8)
["channels"]=>
int(3)
["mime"]=>
string(10) "image/jpeg"
}