From: Richard Russon Date: Fri, 21 Dec 2018 12:31:08 +0000 (+0000) Subject: mbox: fix dodgy stat buffer X-Git-Tag: 2019-10-25~423 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2da30644d7f41286943be537f915f5d5b2b49ee6;p=neomutt mbox: fix dodgy stat buffer --- diff --git a/mbox/mbox.c b/mbox/mbox.c index dcdcf8578..cca4a607e 100644 --- a/mbox/mbox.c +++ b/mbox/mbox.c @@ -1772,26 +1772,26 @@ static int mmdf_msg_padding_size(struct Mailbox *m) */ static int mbox_mbox_check_stats(struct Mailbox *m, int flags) { - struct stat *sb = { 0 }; - stat(m->path, sb); + struct stat sb = { 0 }; + stat(m->path, &sb); bool new_or_changed; if (CheckMboxSize) - new_or_changed = (sb->st_size > m->size); + new_or_changed = (sb.st_size > m->size); else { new_or_changed = - (mutt_file_stat_compare(sb, MUTT_STAT_MTIME, sb, MUTT_STAT_ATIME) > 0) || + (mutt_file_stat_compare(&sb, MUTT_STAT_MTIME, &sb, MUTT_STAT_ATIME) > 0) || (m->newly_created && - (mutt_file_stat_compare(sb, MUTT_STAT_CTIME, sb, MUTT_STAT_MTIME) == 0) && - (mutt_file_stat_compare(sb, MUTT_STAT_CTIME, sb, MUTT_STAT_ATIME) == 0)); + (mutt_file_stat_compare(&sb, MUTT_STAT_CTIME, &sb, MUTT_STAT_MTIME) == 0) && + (mutt_file_stat_compare(&sb, MUTT_STAT_CTIME, &sb, MUTT_STAT_ATIME) == 0)); } if (new_or_changed) { if (!MailCheckRecent || - (mutt_file_stat_timespec_compare(sb, MUTT_STAT_MTIME, &m->last_visited) > 0)) + (mutt_file_stat_timespec_compare(&sb, MUTT_STAT_MTIME, &m->last_visited) > 0)) { m->has_new = true; } @@ -1799,13 +1799,13 @@ static int mbox_mbox_check_stats(struct Mailbox *m, int flags) else if (CheckMboxSize) { /* some other program has deleted mail from the folder */ - m->size = (off_t) sb->st_size; + m->size = (off_t) sb.st_size; } - if (m->newly_created && (sb->st_ctime != sb->st_mtime || sb->st_ctime != sb->st_atime)) + if (m->newly_created && (sb.st_ctime != sb.st_mtime || sb.st_ctime != sb.st_atime)) m->newly_created = false; - if (mutt_file_stat_timespec_compare(sb, MUTT_STAT_MTIME, &m->stats_last_checked) > 0) + if (mutt_file_stat_timespec_compare(&sb, MUTT_STAT_MTIME, &m->stats_last_checked) > 0) { struct Context *ctx = mx_mbox_open(m, NULL, MUTT_READONLY | MUTT_QUIET | MUTT_NOSORT | MUTT_PEEK);