Skip to content

Commit f4efb88

Browse files
committed
Merge branch 'PHP-8.3'
2 parents d105257 + 82e9ba2 commit f4efb88

File tree

3 files changed

+71
-1
lines changed

3 files changed

+71
-1
lines changed

ext/standard/image.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,20 @@ static int php_skip_variable(php_stream * stream)
394394
}
395395
/* }}} */
396396

397+
static size_t php_read_stream_all_chunks(php_stream *stream, char *buffer, size_t length)
398+
{
399+
size_t read_total = 0;
400+
do {
401+
ssize_t read_now = php_stream_read(stream, buffer, length - read_total);
402+
read_total += read_now;
403+
if (read_now < stream->chunk_size && read_total != length) {
404+
return 0;
405+
}
406+
} while (read_total < length);
407+
408+
return read_total;
409+
}
410+
397411
/* {{{ php_read_APP */
398412
static int php_read_APP(php_stream * stream, unsigned int marker, zval *info)
399413
{
@@ -410,7 +424,7 @@ static int php_read_APP(php_stream * stream, unsigned int marker, zval *info)
410424

411425
buffer = emalloc(length);
412426

413-
if (php_stream_read(stream, buffer, (size_t) length) != length) {
427+
if (php_read_stream_all_chunks(stream, buffer, length) != length) {
414428
efree(buffer);
415429
return 0;
416430
}

ext/standard/tests/image/bug75708.jpg

33.8 KB
Loading
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
--TEST--
2+
Bug #75708 (getimagesize with "&$imageinfo" fails on StreamWrappers)
3+
--FILE--
4+
<?php
5+
6+
class FSStreamWrapper {
7+
function stream_open($file, $mode) {
8+
$this->handle = fopen(str_replace('fs://', __DIR__ . '/', $file), $mode);
9+
return true;
10+
}
11+
function stream_read($count) {
12+
return fread($this->handle, $count);
13+
}
14+
function stream_eof() {
15+
return feof($this->handle);
16+
}
17+
function stream_seek($offset, $whence) {
18+
return fseek($this->handle, $offset, $whence) === 0;
19+
}
20+
function stream_stat() {
21+
return fstat($this->handle);
22+
}
23+
function url_stat($file) {
24+
return stat(str_replace('fs://', '', $file));
25+
}
26+
function stream_tell() {
27+
return ftell($this->handle);
28+
}
29+
function stream_close() {
30+
fclose($this->handle);
31+
}
32+
}
33+
34+
stream_register_wrapper('fs', 'FSStreamWrapper');
35+
36+
var_dump(getimagesize('fs://bug75708.jpg', $info));
37+
38+
?>
39+
--EXPECT--
40+
array(7) {
41+
[0]=>
42+
int(10)
43+
[1]=>
44+
int(10)
45+
[2]=>
46+
int(2)
47+
[3]=>
48+
string(22) "width="10" height="10""
49+
["bits"]=>
50+
int(8)
51+
["channels"]=>
52+
int(3)
53+
["mime"]=>
54+
string(10) "image/jpeg"
55+
}
56+

0 commit comments

Comments
 (0)