PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Mail » Mail_Mbox » Bug #4223

mbox files gets corrupted when multiple clients modify it

Details

Submitted2005-04-26 10:48 UTC
Frommarkus at emedia-solutions-wolf dot de
Assignedcweiske
StatusClosed
PackageMail_Mbox
PHP Version4.3.10
OSDebian Linux
Roadmaps(Not assigned)

Comments

[2005-04-26 10:48 UTC] markus at emedia-solutions-wolf dot de

Description:
------------
If multiple clients read and modify the same mbox file, then Mail_Mbox corrupts it.
This is caused because this start and end byte position change when a mail gets modified.
This isn't tracked by Mail_Mbox and the next read and update will destroy the mbox file because of wrong start/end byte position...

Reproduce code:
---------------
Just run the test supplied in the documentation in a long running loop doing all the same all the while with the open mbox file.
Then start mutt and flag a mail as new or old or whatever.

The php script must not be in a loop, but imagine it is reading a mbox file at the same moment when mutt edits it.
(This is allowed and recommended by the mbox format specs)

Expected result:
----------------
A correct mbox file anytime.

Actual result:
--------------
A corrupted mbox file.

[2005-04-26 11:01 UTC] markus at emedia-solutions-wolf dot de

Best solution would be testing if start and end byte positions are valid before reading and writing to mbox.
And also request a lock on the mbox file during write operations.