From 88dbe358e039c08cf1675add08511f95f733ea7e Mon Sep 17 00:00:00 2001 From: Ilia Alshanetsky Date: Thu, 13 Nov 2008 18:22:23 +0000 Subject: [PATCH] MFB: Fixed a bug inside dba_replace() that could cause file truncation with invalid keys --- NEWS | 2 ++ ext/dba/libinifile/inifile.c | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) 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) { -- 2.40.0