SOURCES: tpop3d-mailsize.patch (NEW) Prevent tpop3d from failing w...

arekm arekm at pld-linux.org
Fri Mar 28 19:53:41 CET 2008


Author: arekm                        Date: Fri Mar 28 18:53:41 2008 GMT
Module: SOURCES                       Tag: HEAD
---- Log message:
Prevent tpop3d from failing when S= tag file size is different from real file size.

---- Files affected:
SOURCES:
   tpop3d-mailsize.patch (NONE -> 1.1)  (NEW)

---- Diffs:

================================================================
Index: SOURCES/tpop3d-mailsize.patch
diff -u /dev/null SOURCES/tpop3d-mailsize.patch:1.1
--- /dev/null	Fri Mar 28 19:53:41 2008
+++ SOURCES/tpop3d-mailsize.patch	Fri Mar 28 19:53:36 2008
@@ -0,0 +1,33 @@
+diff --git a/maildir.c b/maildir.c
+index 606dc88..d006597 100644
+--- a/maildir.c
++++ b/maildir.c
+@@ -497,7 +497,9 @@ static int open_message_file(struct indexpoint *m) {
+  * us, in which case we make some effort to find the new version. */
+ int maildir_sendmessage(const mailbox M, connection c, const int i, int n) {
+     struct indexpoint *m;
++    struct stat st;
+     int fd, status;
++    size_t real_size;
+     
+     if (!M || i < 0 || i >= M->num) {
+         /* Shouldn't happen. */
+@@ -515,8 +517,17 @@ int maildir_sendmessage(const mailbox M, connection c, const int i, int n) {
+         log_print(LOG_ERR, "maildir_sendmessage: unable to send message %d", i + 1);
+         return -1;
+     }
++
++    /* fstat is cheap after open. Real size is needed in case when S= size doesn't reflect real file size. */
++    if (fstat(fd, &st) != -1) {
++        real_size = st.st_size;
++	if (m->msglength != st.st_size)
++            log_print(LOG_ERR, _("maildir_sendmessage(%s/%s): inconsistency in mail size: index (%d) vs filesystem (%d)"),
++	        M->name, m->filename, (int)m->msglength, (int)st.st_size);
++    } else
++        real_size = m->msglength;
+     
+-    status = connection_sendmessage(c, fd, 0 /* offset */, 0 /* skip */, m->msglength, n);
++    status = connection_sendmessage(c, fd, 0 /* offset */, 0 /* skip */, real_size, n);
+     close(fd);
+ 
+     return status;
================================================================


More information about the pld-cvs-commit mailing list