]> granicus.if.org Git - php/commitdiff
MFB: Fixed a bug inside dba_replace() that could cause file truncation with
authorIlia Alshanetsky <iliaa@php.net>
Thu, 13 Nov 2008 18:22:23 +0000 (18:22 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Thu, 13 Nov 2008 18:22:23 +0000 (18:22 +0000)
invalid keys

NEWS
ext/dba/libinifile/inifile.c

diff --git a/NEWS b/NEWS
index c66bd6f3ceee98a136d94c9d303a54b4bec059a3..2f55f4d8f95252c537ca83784022b08e2be5a4ed 100644 (file)
--- 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)
index 237ec573864bde7a05886ed7b99933010b1154ac..e5b2940a48836a7c7aeede46375be547e465bc6d 100644 (file)
@@ -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) {