(1) Last-minute sieve patch (updates to latest spec).
[exim.git] / src / src / transports / tf_maildir.c
index bf0aa1572cbad5aa8ff55457f04f90dd6784d6ed..6b9252f4ec6f23c4e47a806399f484e8f35cc2de 100644 (file)
@@ -1,10 +1,10 @@
-/* $Cambridge: exim/src/src/transports/tf_maildir.c,v 1.1 2004/10/07 13:10:02 ph10 Exp $ */
+/* $Cambridge: exim/src/src/transports/tf_maildir.c,v 1.4 2005/02/17 11:58:27 ph10 Exp $ */
 
 /*************************************************
 *     Exim - an Internet mail transport agent    *
 *************************************************/
 
-/* Copyright (c) University of Cambridge 1995 - 2004 */
+/* Copyright (c) University of Cambridge 1995 - 2005 */
 /* See the file NOTICE for conditions of use and distribution. */
 
 /* Functions in support of the use of maildirsize files for handling quotas in
@@ -430,10 +430,19 @@ while (*endptr++ == '\n')
 /* If *endptr is zero, we have successfully parsed the file, and we now have
 the size of the mailbox as cached in the file. The "rules" say that if this
 value indicates that the mailbox is over quota, we must recalculate if there is
-more than one entry in the file, or if the file is older than 15 minutes. */
+more than one entry in the file, or if the file is older than 15 minutes. Also,
+just in case there are weird values in the file, recalculate if either of the
+values is negative. */
 
 if (*endptr == 0)
   {
+  if (size < 0 || filecount < 0)
+    {
+    DEBUG(D_transport) debug_printf("negative value in maildirsize "
+      "(size=%d count=%d): recalculating\n", size, filecount);
+    goto RECALCULATE;
+    }
+
   if (ob->quota_value > 0 &&
       (size + (ob->quota_is_inclusive? message_size : 0) > ob->quota_value ||
         (ob->quota_filecount_value > 0 &&
@@ -444,7 +453,7 @@ if (*endptr == 0)
     struct stat statbuf;
     if (linecount > 1)
       {
-      DEBUG(D_transport) debug_printf("over quota and maildirsizefile has "
+      DEBUG(D_transport) debug_printf("over quota and maildirsize has "
         "more than 1 entry: recalculating\n");
       goto RECALCULATE;
       }