Bug 2687 - Unable to clean an mbox mailbox
Summary: Unable to clean an mbox mailbox
Status: RESOLVED FIXED
Alias: None
Product: Claws Mail (GTK 2)
Classification: Unclassified
Component: Plugins/mailMBOX (show other bugs)
Version: 3.8.1
Hardware: PC Linux
: P3 normal
Assignee: users
URL:
Depends on:
Blocks:
 
Reported: 2012-07-01 11:47 UTC by pv4
Modified: 2012-07-15 06:13 UTC (History)
0 users

See Also:


Attachments
The fix (1.05 KB, patch)
2012-07-01 11:47 UTC, pv4
no flags Details | Diff

Description pv4 2012-07-01 11:47:17 UTC
Created attachment 1123 [details]
The fix

OVERVIEW:
If removing message(s) from an mbox mailbox causes it to have no messages after the removal, then the removed messages return back to the mailbox after claws-mail restart.

STEPS TO REPRODUCE:
0. use claws-mail-3.8.1, mailmbox-1.14.7, linux 3.4.2 (according to mmap manpage, linux-2.6.12 and above are affected),
1. start claws-mail with mailmbox.so plugin enabled,
2. create an empty mbox mailbox, and a folder in it,
3. copy a message to the folder
4. restart claws-mail
5. enter the folder and delete the message
6. restart claws-mail
7. enter the folder

EXPECTED RESULT: folder is empty

ACTUAL RESULT: folder contains the removed message (and it's unread)

EXPLANATION:
When writing mbox file mmap(0, size, ...) is used with zero size (since there
are no messages in the box). mmap returns MAP_FAILED and
MAILBOX_ERROR_FILE error is returned (which I guess causes the newly
created file to not overwrite the old one).

FIX:
Don't call *map functions if size is zero. The loop between mmap and munmap
won't generate segmentation faults since there are no messages to write so we
can leave it as is.
This causes an empty file to be created and MAILMBOX_NO_ERROR is returned
so the new empty file overwrites the old one.
Comment 1 Paul 2012-07-15 06:13:03 UTC
Thanks for your contribution.

Note You need to log in before you can comment on or make changes to this bug.