Bug 137033 - excessive cpu usage while processing malformed headers
Summary: excessive cpu usage while processing malformed headers
Status: RESOLVED UNMAINTAINED
Alias: None
Product: kmail
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: kdepim bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-11-08 12:17 UTC by Dirk Mueller
Modified: 2018-09-04 18:19 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
proposed patch (4.17 KB, patch)
2006-11-08 20:15 UTC, Sune Vuorela
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Dirk Mueller 2006-11-08 12:17:53 UTC
Version:            (using KDE KDE 3.5.5)
Installed from:    Compiled From Sources
OS:                Linux

Sune Vuorela reports that certain messages cause KMail to hang. I'll attach a sample.
Comment 1 Dirk Mueller 2006-11-08 12:21:28 UTC
actually I cannot attach it but it is available under http://mirror.pusling.com/badmail
Comment 2 Dirk Mueller 2006-11-08 18:08:55 UTC
further comment from Sune: 

Notice line 23 which is about 4-500 k of backslashes.
'litb' on #kde-devel talked about start writing a patch for this.

I inspected Mail/inbox/cur and removed line 23 from that file - and after that 
there was no problems with the email. It looks like a bug in the 
header-parsing functions.
Comment 3 Sune Vuorela 2006-11-08 20:15:15 UTC
Created attachment 18472 [details]
proposed patch

 
Johannes Schaub has created a patch for this
Comment 4 Johannes Schaub 2006-11-11 16:46:35 UTC
yeah, i created it and it works fine and _alot_ of faster than the old code. the email shows up within < 1s
Comment 5 Dirk Mueller 2006-11-11 23:45:07 UTC
nice! using QString might be a good solution, given that QByteArray/QCString doesn't have a reserve() method for overcoming the O(n^2) behaviour. however, the local8Bit() conversion is wrong - it should be latin1. 

Comment 6 Sune Vuorela 2006-11-16 01:44:52 UTC
so dirk is saying that the patch would be fine after doing a s/local8Bit/latin1/ over the patch ?

Or have I missed something?
A official approved fix would be nice.

/Sune
Comment 7 Allen Winter 2007-03-06 01:59:39 UTC
I recall discussing this a little on irc.  But I don't remember what we decided.  Dirk, do you remember?  Ingo?

I also think Volker had a libkmime unit test for this.

Please advise if I should commit Sune's patch.
Comment 8 Sune Vuorela 2007-03-06 09:50:41 UTC
we have been shipping this patch in debian for a couple of months. We have gotten one report of some drawbacks with it, but I still consider them less important than a freezing kmail.

A user writes:
<quote>
Since version 4:3.5.5.dfsg.1-2  kmail stopped treating correctly my name in 
the header. The last à in my last name is lost (strangely enough if I write 
it not in the last position of my name in the profile it works without 
problem). Prior to that version it worked without problem. I suspect the 
culprit is
 18_optimize_splitAddressInternal.diff
</quote>

Original report is http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=405867

/Sune
Comment 9 Martin Koller 2009-08-04 15:40:06 UTC
It would be great to have such a problematic mail to test with, as Qt4 now offers QByteArray::reserve().
Note: A quick test with a mail where the displayName field has about 700000 characters did not show a problem with the function shown in this patch (KPIMUtils::EmailParseResult splitAddressInternal) but with QByteArray::replace called from QUrl::setEncodedUrl  called from KHTLPart ...
So the problem I see lies within Qt - but maybe the original problem can still be shown ?
Comment 10 Andrew Crouthamel 2018-09-04 18:19:39 UTC
Hello! Sorry to be the bearer of bad news, but this version of Kmail has been unmaintained for many years so I am closing this bug. Please try using the latest version of Kmail to see if your issue persists. If it does, please submit a new bug in "kmail2". Thank you!