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

ext/dba/libinifile/inifile.c

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) {