Bug 168870 - [PATCH] mail/qmail: MAILDIRQUOTA Maildir++ support miscalculates file size
[PATCH] mail/qmail: MAILDIRQUOTA Maildir++ support miscalculates file size
Status: Closed FIXED
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s)
Any Any
: Normal Affects Only Me
Assigned To: Renato Botelho
Depends on:
  Show dependency treegraph
Reported: 2012-06-09 00:10 UTC by freebsd
Modified: 2012-10-11 15:41 UTC (History)
1 user (show)

See Also:

qmail-1.03_8.patch (40.11 KB, patch)
2012-06-09 00:10 UTC, freebsd
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description freebsd 2012-06-09 00:10:09 UTC
The qmail-maildir++ patch, which is fetched and enabled in case the
MAILDIRQUOTA option has been enabled miscalculates the file size in
qmail-local.c because the first two lines of the mail file (Return-Path and
Delivered-To) are not taken into account. As a result, the filesize
part of the S=<filesize> component of the Maildir++ compatible filename
is always too low. This hasn't been noticed for many years, since the
impact on quota calculation was negligible (typically less than 100
bytes per e-mail). I stumbled over this, because mail/dovecot2 2.1.7 is
actually comparing the value of S= with the result of stat and ends the
connection to correct the problem. This is also affecting any other
program using Maildir++, so this definitely needs to be fixed. The
specification of the Maildir++ format clearly states that the S=xxx
should match the size of the file (see also

The following line in the patch is the root of the problem:

s += fmt_ulong(s,st.st_size); *s++ = 0;

which should be:

s += fmt_ulong(s,st.st_size+rpline.len+dtline.len); *s++ = 0;

Added file(s):
- files/extra-patch-qmail-maildir++

Port maintainer (garga@FreeBSD.org) is cc'd.

Generated with FreeBSD Port Tools 0.99_6 (mode: change, diff: suffix)

Fix: The original patch has been done in 2005 by Bill Shupp, as far as I can
tell he's not really interested in it, so contacting him seems
pointless. Also, the patch that the port has been using until now was
modified (Bill's message was removed) and fetched from
http://www.alexdupre.com, which again provides no further information.

Since it seems painful to change this upstream, I removed the patch
from distfiles and placed the corrected patch into the files directory
of port skeleton. I changed Makefile to use this patch and bumped the
How-To-Repeat: Install mail/qmail using the MAILDIRQUOTA option. Create a
.qmail-<alias> file and make it deliver to a maildir. Compare the size
of the resulting file with the value of S= in the filename.
Comment 1 Edwin Groothuis freebsd_committer 2012-06-09 07:40:00 UTC
Responsible Changed
From-To: freebsd-ports-bugs->garga

Over to maintainer (via the GNATS Auto Assign Tool)
Comment 2 freebsd 2012-10-06 00:47:23 UTC
Any chance to look into this? It's clearly not super critical, but
quite of a nuisance for people relying on this feature.

Thank you,

Michael Gmelin
Comment 3 Renato Botelho freebsd_committer 2012-10-11 15:41:15 UTC
State Changed
From-To: open->closed

Committed. Thanks!