1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

phar: Fix broken return value of fflush() for phar file entries

The flush functions always return EOF, even in the success path.
The success path should return 0 to indicate success.

Closes GH-20474.
This commit is contained in:
Niels Dossche
2025-11-13 23:06:21 +01:00
parent 48b19a8ede
commit 2f9d86b677
5 changed files with 29 additions and 3 deletions

1
NEWS
View File

@@ -21,6 +21,7 @@ PHP NEWS
- Phar:
. Fixed bug GH-20442 (Phar does not respect case-insensitiveness of
__halt_compiler() when reading stub). (ndossche, TimWolla)
. Fix broken return value of fflush() for phar file entries. (ndossche)
- PHPDBG:
. Fixed ZPP type violation in phpdbg_get_executable() and phpdbg_end_oplog().

View File

@@ -3225,7 +3225,7 @@ int phar_flush(phar_archive_data *phar, char *user_stub, zend_long len, int conv
return EOF;
}
return EOF;
return 0;
cleanup:
if (shared_cfp != NULL) {

View File

@@ -1378,6 +1378,6 @@ nostub:
php_stream_close(newfile);
}
}
return EOF;
return 0;
}
/* }}} */

View File

@@ -0,0 +1,25 @@
--TEST--
fflush() on phar file should report success
--EXTENSIONS--
phar
--INI--
phar.readonly=0
--FILE--
<?php
$phar = new Phar(__DIR__.'/fflush_phar_file_report_success.phar');
$phar->addFromString('test', 'contents');
unset($phar);
$f = fopen('phar://' . __DIR__.'/fflush_phar_file_report_success.phar/test', 'w');
var_dump(fflush($f));
var_dump(fclose($f));
?>
--CLEAN--
<?php
@unlink(__DIR__.'/fflush_phar_file_report_success.phar');
?>
--EXPECT--
bool(true)
bool(true)

View File

@@ -1542,6 +1542,6 @@ nocentralerror:
if (closeoldfile) {
php_stream_close(oldfile);
}
return EOF;
return 0;
}
/* }}} */