From: Ilia Alshanetsky Date: Thu, 13 Nov 2008 18:22:23 +0000 (+0000) Subject: MFB: Fixed a bug inside dba_replace() that could cause file truncation with X-Git-Tag: php-5.2.7RC4~25 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=88dbe358e039c08cf1675add08511f95f733ea7e;p=php MFB: Fixed a bug inside dba_replace() that could cause file truncation with invalid keys --- diff --git a/NEWS b/NEWS index c66bd6f3ce..2f55f4d8f9 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,8 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ?? Nov 2008, PHP 5.2.7 - Fixed sybase_fetch_*() to continue reading after CS_ROW_FAIL status (Timm) +- Fixed a bug inside dba_replace() that could cause file truncation with + invalid keys. (Ilia) - Fixed bug #46543 (ibase_trans() memory leaks when using wrong parameters). (Felipe) diff --git a/ext/dba/libinifile/inifile.c b/ext/dba/libinifile/inifile.c index 237ec57386..e5b2940a48 100644 --- a/ext/dba/libinifile/inifile.c +++ b/ext/dba/libinifile/inifile.c @@ -508,7 +508,9 @@ static int inifile_delete_replace_append(inifile *dba, const key_type *key, cons /* 5 */ if (ret == SUCCESS) { - ret = inifile_truncate(dba, append ? pos_grp_next : pos_grp_start TSRMLS_CC); /* writes error on fail */ + if (!value || (key->name && strlen(key->name))) { + ret = inifile_truncate(dba, append ? pos_grp_next : pos_grp_start TSRMLS_CC); /* writes error on fail */ + } } if (ret == SUCCESS) {