summaryrefslogtreecommitdiff
path: root/ext/dba/dba_flatfile.c
diff options
context:
space:
mode:
authorMarcus Boerger <helly@php.net>2003-12-14 22:08:18 +0000
committerMarcus Boerger <helly@php.net>2003-12-14 22:08:18 +0000
commit43d06f50e0014e7a43c83276772e6a737b082dfa (patch)
tree830d5c05803b460af3f62883f12e025e04272dc0 /ext/dba/dba_flatfile.c
parent620bf0c37f0fdc14304f026eb9fc9efb15eceebc (diff)
downloadphp-git-43d06f50e0014e7a43c83276772e6a737b082dfa.tar.gz
- Fix Bug #26304 Unexpected data loss when opening dba file
- Correct handling for flatfile handler
Diffstat (limited to 'ext/dba/dba_flatfile.c')
-rw-r--r--ext/dba/dba_flatfile.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/ext/dba/dba_flatfile.c b/ext/dba/dba_flatfile.c
index feba2c8da8..fa1232779a 100644
--- a/ext/dba/dba_flatfile.c
+++ b/ext/dba/dba_flatfile.c
@@ -41,6 +41,17 @@
DBA_OPEN_FUNC(flatfile)
{
+ int fd, flags;
+
+ if (info->mode != DBA_READER) {
+ if (SUCCESS != php_stream_cast(info->fp, PHP_STREAM_AS_FD, (void*)&fd, 1)) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not cast stream");
+ return FAILURE;
+ }
+ flags = fcntl(fd, F_SETFL);
+ fcntl(fd, F_SETFL, flags & ~O_APPEND);
+ }
+
info->dbf = pemalloc(sizeof(flatfile), info->flags&DBA_PERSISTENT);
memset(info->dbf, 0, sizeof(flatfile));