php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #71514 Bad dba_replace condition because of wrong API usage
Submitted: 2016-02-03 15:46 UTC Modified: 2016-08-25 14:08 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: aurelien dot dudouit at corp dot ovh dot com Assigned: cmb
Status: Closed Package: DBM/DBA related
PHP Version: 5.6.18 OS:
Private report: No CVE-ID:
 [2016-02-03 15:46 UTC] aurelien dot dudouit at corp dot ovh dot com
Description:
------------
dba_replace fails, ending in 'Could not copy group [x - x] to temporary stream' because of a bad condition.
php_stream_copy_to_stream() has been replaced since 5.5 with php_stream_copy_to_stream_ex() without updating the conditions into which it's been enclosed; the newer function returns SUCCESS which is set to 0, hence the following check isn't valid anymore because it's expecting non-zero value (size_t):
if (!php_stream_copy_to_stream_ex(...)) {

It's been fixed in PHP7.0:
if (SUCCESS != php_stream_copy_to_stream_ex(...)) {

A patch has already been proposed two years ago, see: http://git.php.net/?p=php-src.git;a=commit;h=9e309a2d10d9696d047ecb442


Test script:
---------------
<?php
$db = dba_open("foo.inifile", 'c', 'inifile');

dba_insert('foo', 'value1', $db);
dba_replace('foo', 'value2', $db);
echo dba_fetch('foo', $db);

dba_close($db);
?>

Expected result:
----------------
All PHP versions >=5.3:
value2

Actual result:
--------------
PHP5.6 and PHP5.5:
value1

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-02-11 10:05 UTC] aurelien dot dudouit at corp dot ovh dot com
-PHP Version: 5.6.17 +PHP Version: 5.6.18
 [2016-02-11 10:05 UTC] aurelien dot dudouit at corp dot ovh dot com
Reflected onto latest 5.6 release (5.6.18).
 [2016-08-25 14:08 UTC] cmb@php.net
-Summary: Bad dba_replace condition because of Zend MM wrong use +Summary: Bad dba_replace condition because of wrong API usage -Status: Open +Status: Verified -Assigned To: +Assigned To: cmb
 [2016-08-25 15:00 UTC] cmb@php.net
Automatic comment on behalf of cmbecker69@gmx.de
Revision: http://git.php.net/?p=php-src.git;a=commit;h=bd8112afe076cd975fbfcf82b659f6420317de70
Log: Fix #71514: Bad dba_replace condition because of wrong API usage
 [2016-08-25 15:00 UTC] cmb@php.net
-Status: Verified +Status: Closed
 [2016-10-17 10:09 UTC] bwoebi@php.net
Automatic comment on behalf of cmbecker69@gmx.de
Revision: http://git.php.net/?p=php-src.git;a=commit;h=bd8112afe076cd975fbfcf82b659f6420317de70
Log: Fix #71514: Bad dba_replace condition because of wrong API usage
 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Mon Feb 20 15:01:35 2017 UTC