]> granicus.if.org Git - neomutt/commitdiff
mbox: fix dodgy stat buffer
authorRichard Russon <rich@flatcap.org>
Fri, 21 Dec 2018 12:31:08 +0000 (12:31 +0000)
committerRichard Russon <rich@flatcap.org>
Fri, 21 Dec 2018 12:31:08 +0000 (12:31 +0000)
mbox/mbox.c

index dcdcf8578ceec635ff80fd9fcdedd8cce713c48c..cca4a607e663977c25301d041c607e38d6bca1b0 100644 (file)
@@ -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);