Re: [PATCH] Detect corrupted content-length in Maildirs
On Fri, Aug 13, 2010 at 1:35 AM, Michael Elkins <me@xxxxxxxxxxx> wrote:
> On Fri, Aug 13, 2010 at 01:12:59AM +0200, Michael Hanselmann wrote:
>> + if (h->content->length > 0 &&
>> + (h->content->offset + h->content->length) != st.st_size)
>> + {
>> + dprint (1, (debugfile, "maildir_parse_message: bad content-length "
>> + "in message %d (cl=" OFF_T_FMT ")\n",
>> + h->index, h->content->length));
>> + h->content->length = -1;
>> + }
>> +
>> if (h->content->length <= 0)
>> h->content->length = st.st_size - h->content->offset;
>
> I think this whole block can be reduced to always setting
> h->content->length. All the necessary information is there, and I don't see
> any other place where it is adjusted.
You're right. I'll send another patch tomorrow.
> It is curious how the corruption happened, however. It appears something
> damaged the cache itself.
Unfortunately I've no way to find out. I was converting old mails and
it might even have been the sender.
Another mail didn't end with a newline and led to similar corruption
("</html>^A^A^A^A"), but I haven't been able to figure out a good way
to work around it. Should I file a ticket for this case?
Michael