mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Merge branch 'PHP-7.4'
This commit is contained in:
commit
f10eb9f756
3 changed files with 44 additions and 19 deletions
|
@ -91,9 +91,9 @@ static inline void strip_header(char *header_bag, char *lc_header_bag,
|
||||||
) {
|
) {
|
||||||
char *header_start = header_bag + (lc_header_start - lc_header_bag);
|
char *header_start = header_bag + (lc_header_start - lc_header_bag);
|
||||||
char *lc_eol = strchr(lc_header_start, '\n');
|
char *lc_eol = strchr(lc_header_start, '\n');
|
||||||
char *eol = header_start + (lc_eol - lc_header_start);
|
|
||||||
|
|
||||||
if (lc_eol) {
|
if (lc_eol) {
|
||||||
|
char *eol = header_start + (lc_eol - lc_header_start);
|
||||||
size_t eollen = strlen(lc_eol);
|
size_t eollen = strlen(lc_eol);
|
||||||
|
|
||||||
memmove(lc_header_start, lc_eol+1, eollen);
|
memmove(lc_header_start, lc_eol+1, eollen);
|
||||||
|
|
27
ext/standard/tests/streams/bug78506.phpt
Normal file
27
ext/standard/tests/streams/bug78506.phpt
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
--TEST--
|
||||||
|
Bug #78506: Error in a php_user_filter::filter() is not reported
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class MyFilter extends php_user_filter {
|
||||||
|
public function filter($in, $out, &$consumed, $closing)
|
||||||
|
{
|
||||||
|
stream_bucket_make_writeable($in);
|
||||||
|
return PSFS_ERR_FATAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
stream_filter_register('filtername', MyFilter::class);
|
||||||
|
|
||||||
|
$source_resource = fopen('php://memory', 'rb+');
|
||||||
|
fwrite($source_resource, 'Test data');
|
||||||
|
rewind($source_resource);
|
||||||
|
|
||||||
|
stream_filter_prepend($source_resource,'filtername',STREAM_FILTER_READ);
|
||||||
|
|
||||||
|
var_dump(stream_copy_to_stream($source_resource, fopen('php://memory', 'wb')));
|
||||||
|
|
||||||
|
?>
|
||||||
|
--EXPECT--
|
||||||
|
bool(false)
|
|
@ -1586,33 +1586,31 @@ PHPAPI int _php_stream_copy_to_stream_ex(php_stream *src, php_stream *dest, size
|
||||||
while(1) {
|
while(1) {
|
||||||
size_t readchunk = sizeof(buf);
|
size_t readchunk = sizeof(buf);
|
||||||
ssize_t didread;
|
ssize_t didread;
|
||||||
|
char *writeptr;
|
||||||
|
|
||||||
if (maxlen && (maxlen - haveread) < readchunk) {
|
if (maxlen && (maxlen - haveread) < readchunk) {
|
||||||
readchunk = maxlen - haveread;
|
readchunk = maxlen - haveread;
|
||||||
}
|
}
|
||||||
|
|
||||||
didread = php_stream_read(src, buf, readchunk);
|
didread = php_stream_read(src, buf, readchunk);
|
||||||
|
if (didread <= 0) {
|
||||||
|
*len = haveread;
|
||||||
|
return didread < 0 ? FAILURE : SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
if (didread > 0) {
|
towrite = didread;
|
||||||
/* extra paranoid */
|
writeptr = buf;
|
||||||
char *writeptr;
|
haveread += didread;
|
||||||
|
|
||||||
towrite = didread;
|
while (towrite) {
|
||||||
writeptr = buf;
|
ssize_t didwrite = php_stream_write(dest, writeptr, towrite);
|
||||||
haveread += didread;
|
if (didwrite <= 0) {
|
||||||
|
*len = haveread - (didread - towrite);
|
||||||
while (towrite) {
|
return FAILURE;
|
||||||
ssize_t didwrite = php_stream_write(dest, writeptr, towrite);
|
|
||||||
if (didwrite <= 0) {
|
|
||||||
*len = haveread - (didread - towrite);
|
|
||||||
return FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
towrite -= didwrite;
|
|
||||||
writeptr += didwrite;
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
break;
|
towrite -= didwrite;
|
||||||
|
writeptr += didwrite;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (maxlen - haveread == 0) {
|
if (maxlen - haveread == 0) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue