summaryrefslogtreecommitdiffstats
path: root/mh.c
diff options
context:
space:
mode:
authorKevin McCarthy <kevin@8t8.us>2016-08-01 18:25:28 -0700
committerKevin McCarthy <kevin@8t8.us>2016-08-01 18:25:28 -0700
commit9ff7dfc11556f93f9d29960c262d16392dec3a03 (patch)
tree35427848a659c2a4b309f2173dad82b1a049dd02 /mh.c
parente6bafd5779a02882a20b1f5d65b6598341217ed6 (diff)
Use a different flag in mx_open_mailbox_append() when mailbox doesn't exist.
The previous commit re-used MUTT_NEWFOLDER, but the meaning of that flag is slightly different: it causes mbox to use fopen with mode "w", and is used only for the case of a brand-new mktemp-generated mbox. Setting it for other non-existing mbox files leads to a race condition between the stat and the fopen/lock, and so could end up truncating an existing mailbox created in-between! Create a different flag, MUTT_APPENDNEW to notify the open_append() functions that the mailbox doesn't exist. Change maildir and mh to check for that flag to create their directory structures.
Diffstat (limited to 'mh.c')
-rw-r--r--mh.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/mh.c b/mh.c
index 3d969f62..f7ce25fc 100644
--- a/mh.c
+++ b/mh.c
@@ -1294,7 +1294,7 @@ static int maildir_open_mailbox_append (CONTEXT *ctx, int flags)
{
char tmp[_POSIX_PATH_MAX];
- if (flags & MUTT_NEWFOLDER)
+ if (flags & MUTT_APPENDNEW)
{
if (mkdir (ctx->path, S_IRWXU))
{
@@ -1346,7 +1346,7 @@ static int mh_open_mailbox_append (CONTEXT *ctx, int flags)
char tmp[_POSIX_PATH_MAX];
int i;
- if (flags & MUTT_NEWFOLDER)
+ if (flags & MUTT_APPENDNEW)
{
if (mkdir (ctx->path, S_IRWXU))
{