Bug 65615 - kmail crashes with message: kmail: FATAL: q codec lies about it's maxDecodedSizeFor()
Summary: kmail crashes with message: kmail: FATAL: q codec lies about it's maxDecodedS...
Status: RESOLVED FIXED
Alias: None
Product: kmail
Classification: Applications
Component: mime (show other bugs)
Version: unspecified
Platform: unspecified Linux
: NOR crash
Target Milestone: ---
Assignee: kdepim bugs
URL:
Keywords:
: 66640 68560 68750 69826 75073 (view as bug list)
Depends on:
Blocks:
 
Reported: 2003-10-06 19:19 UTC by Brian Waite
Modified: 2007-12-11 20:21 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
This mail causes the kmail crash (2.15 KB, message/rfc822)
2003-10-06 19:20 UTC, Brian Waite
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Brian Waite 2003-10-06 19:19:56 UTC
Version:           Qt: 3.1.2 KDE: 3.1.4 KMail: 1.5.4  (using KDE KDE 3.1.4)
Installed from:    Unspecified Unix
Compiler:          gcc version 3.2.2 20030217 (Yellow Dog Linux 3.0 3.2.2-2a)  PowerPC
OS:          Linux

This message (and others like it) always cuase a SIGABRT when they open in the preview pane. I think it has to do the the To or From field containing the char set encoded but I don't know:

kmail stdout: 

[waite@dayton:waite]$ kmail
libkdenetwork: creating new pgp object
libkdenetwork: Kpgp: gpg found
[waite@dayton:waite]$ libkdenetwork: Kpgp: assign pgp - gpg
libkdenetwork: GnuPG exited with exit status 0
libkdenetwork: gpg stderr:
libkdenetwork: libkdenetwork: pgp cmd = LANGUAGE=C gpg --batch --decrypt
gpg: WARNING: --honor-http-proxy is a deprecated option.
gpg: please use "--keyserver-options honor-http-proxy" instead
gpg: Warning: using insecure memory!
gpg: please see http://www.gnupg.org/faq.html for more information
gpg: Signature made Mon 06 Oct 2003 12:45:18 PM EDT using DSA key ID 4BBE2A8F
gpg: Good signature from "Brian Waite <waite@skycomputers.com>"
libkdenetwork:
libkdenetwork: Message was signed on 'Mon 06 Oct 2003 12:45:18 PM EDT'
libkdenetwork: Message was signed with key '4BBE2A8F'
libkdenetwork: GnuPG exited with exit status 0
libkdenetwork: gpg stderr:
libkdenetwork: libkdenetwork: pgp cmd = LANGUAGE=C gpg --batch --list-public-keys --with-fingerprint --with-colons --fixed-list-mode --no-expensive-trust-checks
gpg: WARNING: --honor-http-proxy is a deprecated option.
gpg: please use "--keyserver-options honor-http-proxy" instead
gpg: Warning: using insecure memory!
gpg: please see http://www.gnupg.org/faq.html for more information
libkdenetwork:
libkdenetwork: GnuPG exited with exit status 0
libkdenetwork: gpg stderr:
libkdenetwork: libkdenetwork: pgp cmd = LANGUAGE=C gpg --batch --list-public-keys --with-fingerprint --with-colons --fixed-list-mode 0x4BBE2A8F
gpg: WARNING: --honor-http-proxy is a deprecated option.
gpg: please use "--keyserver-options honor-http-proxy" instead
gpg: Warning: using insecure memory!
gpg: please see http://www.gnupg.org/faq.html for more information
libkdenetwork:
kmail: FATAL: q codec lies about it's maxDecodedSizeFor()
*** KMail got signal 6 (Crashing)

Will attache problem mail
Comment 1 Brian Waite 2003-10-06 19:20:53 UTC
Created attachment 2700 [details]
This mail causes the kmail crash
Comment 2 Brian Waite 2003-10-06 19:43:26 UTC
Here is a backtrace: 
[New Thread 16384 (LWP 30936)] 
0x0e63a2c4 in __libc_waitpid (pid=30982, stat_loc=0x0, options=0) 
    at ../sysdeps/unix/sysv/linux/waitpid.c:28 
	in ../sysdeps/unix/sysv/linux/waitpid.c 
#0  0x0e63a2c4 in __libc_waitpid (pid=30982, stat_loc=0x0, options=0) 
    at ../sysdeps/unix/sysv/linux/waitpid.c:28 
#1  0x0f16592c in KCrash::defaultCrashHandler(int) () 
   from /usr/lib/libkdecore.so.4 
#2  0x0e638cec in __pthread_sighandler (signo=241385996, ctx=0x0) 
    at sighandler.c:38 
#3  <signal handler called> 
#4  0x0e2e0c1c in kill () at finddomain.c:145 
#5  0x0e6359c4 in pthread_kill (thread=30936, signo=6) at signals.c:65 
#6  0x0e635e50 in __pthread_raise (sig=6) at signals.c:187 
#7  0x0e2e09fc in raise (sig=604121218) 
    at ../linuxthreads/sysdeps/unix/sysv/linux/raise.c:34 
#8  0x0e2e211c in abort () at ../sysdeps/generic/abort.c:88 
#9  0x0f10500c in kDebugBackend(unsigned short, unsigned, char const*) () 
   from /usr/lib/libkdecore.so.4 
#10 0x0f1056b8 in kdbgstream::flush() () from /usr/lib/libkdecore.so.4 
#11 0x101c9a68 in endl(kdbgstream&) () 
#12 0x0f9a5048 in KMime::Codec::decode(QMemArray<char> const&, bool) const () 
   from /usr/lib/libkdenetwork.so.2 
#13 0x1013de64 in KMMsgBase::decodeRFC2047String(QCString const&) () 
#14 0x1003a590 in KMMessage::headerField(QCString const&) const () 
#15 0x100398ec in KMMessage::subject() const () 
#16 0x100f9204 in KMReaderWin::writeMsgHeader(KMMessage*, bool) () 
#17 0x100f8864 in KMReaderWin::parseMsg(KMMessage*, bool) () 
#18 0x100f4340 in KMReaderWin::parseMsg() () 
#19 0x100f1ab8 in KMReaderWin::updateReaderWin() () 
#20 0x1010859c in KMReaderWin::qt_invoke(int, QUObject*) () 
#21 0x0eb0d2d0 in QObject::activate_signal(QConnectionList*, QUObject*) () 
   from /usr/lib/libqt-mt.so.3 
#22 0x0eb0d0cc in QObject::activate_signal(int) () from /usr/lib/libqt-mt.so.3 
#23 0x0edf61a8 in QTimer::timeout() () from /usr/lib/libqt-mt.so.3 
#24 0x0eb2eb5c in QTimer::event(QEvent*) () from /usr/lib/libqt-mt.so.3 
#25 0x0eaa9784 in QApplication::internalNotify(QObject*, QEvent*) () 
   from /usr/lib/libqt-mt.so.3 
#26 0x0eaa9028 in QApplication::notify(QObject*, QEvent*) () 
   from /usr/lib/libqt-mt.so.3 
#27 0x0f0f62dc in KApplication::notify(QObject*, QEvent*) () 
   from /usr/lib/libkdecore.so.4 
#28 0x0ea83674 in QEventLoop::activateTimers() () from /usr/lib/libqt-mt.so.3 
#29 0x0ea617dc in QEventLoop::processEvents(unsigned) () 
   from /usr/lib/libqt-mt.so.3 
#30 0x0eabeb80 in QEventLoop::enterLoop() () from /usr/lib/libqt-mt.so.3 
#31 0x0eabe980 in QEventLoop::exec() () from /usr/lib/libqt-mt.so.3 
#32 0x0eaa99f8 in QApplication::exec() () from /usr/lib/libqt-mt.so.3 
#33 0x101759c4 in main () 
#34 0x0e2cb04c in __libc_start_main (argc=2147481968, ubp_av=0x7ffff8b0,  
    ubp_ev=0x44022882, auxvec=0x10237398, rtld_fini=0, stinfo=0x101f0000,  
    stack_on_entry=0x44022882) at ../sysdeps/powerpc/elf/libc-start.c:178 
 
Comment 3 Marc Mutz 2003-10-06 22:42:12 UTC
Subject: Re:  New: kmail crashes with message: kmail: FATAL: q codec lies about it's maxDecodedSizeFor()

[ Don, do you have access to a KMail on PPC? If so, can you confirm the 
crash w/ the testcase in #65615? ]

On Monday 06 October 2003 19:19, Brian Waite wrote:
<snip>
> kmail: FATAL: q codec lies about it's maxDecodedSizeFor()
> *** KMail got signal 6 (Crashing)
<snip>

It works for me, in KMail/HEAD. maxDecodedSize() hasn't changed since 
3.1.4... Please confirm that in your copy of libkdenetwork/
kmime_codec_qp.h, Rfc2047QEncodingCodec::maxDecodedSizeFor() returns 
the same value that was passed into it.

The only thing that is obviously different for you than for me is that 
you work on PPC.

> #15 0x100398ec in KMMessage::subject() const () 

Seems to crash in the subject decoding:

> To: "=?ISO-8859-1?Q?Linus_Torvalds?=" <torvalds@osdl.org>
> Cc: "=?ISO-8859-1?Q?kernel_list?=" <linux-kernel@vger.kernel.org>,

These are broken, =?...?= isn't allowed inside quotes...

>  "=?ISO-8859-1?Q??= =?ISO-8859-1?Q?Patrick_Mochel?=" <mochel@osdl.org>

I'd expect _this_ one to crash, if any, since it contains that 
completely bogus =?ISO-8859-1?Q??= with a length of 0. But according to 
the BT it crashes here:

> Subject: =?ISO-8859-1?Q?Re:_pm:_Revert_swsusp_to_2.6.0-test3_?=

The only thing here is that it ends in _ (space), but that counts as any 
other character before decoding.

Please attach gdb to the process and confirm that the value passed in to 
maxDecodedSizeFor() is indeed 37 (the length of the encoded string 
between the last pair of ?'s.

-or-

Try to reproduce it with test_kmime_codec in libkdenetwork/tests.

Marc

Comment 4 Don Sanders 2003-10-07 09:22:45 UTC
Subject: Re:  New: kmail crashes with message: kmail: FATAL: q codec lies about it's maxDecodedSizeFor()

On Tuesday 07 October 2003 06:32, Marc Mutz wrote:
> [ Don, do you have access to a KMail on PPC?

Sadly no :(

I only have OS X on PPC architecture currently, sorry. I intend to 
check our Fink KDE packages at some point but haven't done so yet.

Don.

Comment 5 George Staikos 2003-10-07 09:33:24 UTC
I guess I should try to lend a hand here.  I'll try to reproduce this soon.  
Ping me if you don't hear from me. 
Comment 6 Marc Mutz 2003-10-07 14:57:07 UTC
> I guess I should try to lend a hand here. I'll try to reproduce this soon. 
 
Thanks! 
  
Comment 7 Brian Waite 2003-10-07 15:40:29 UTC
I am willing to help out though I am not a KDE developer. In response to some 
of the questions you ased above: 
> It works for me, in KMail/HEAD. maxDecodedSize() hasn't changed since  
> 3.1.4... Please confirm that in your copy of libkdenetwork/  
> kmime_codec_qp.h, Rfc2047QEncodingCodec::maxDecodedSizeFor() returns  
> the same value that was passed into it.  
Yes, Rfc2047QEncodingCodec::maxDecodedSizeFor() returns the same as was passed 
in. 
 
 
I can run the test_kmime_codec if you can give me the parameters to call it 
with. I looked at the usage but I don't know the encoding codec to use. 
 
Brian 
Comment 8 Brian Waite 2003-10-07 15:41:24 UTC
A little more data here. Kmail 1.5.3 on my other PPC works fine with this 
message. 
[waite@enigmac4:waite]$ kmail --version 
Qt: 3.1.2 
KDE: 3.1.3 
KMail: 1.5.3 
 
I wonder if that helps? 
Brian 
Comment 9 Vincent Strubel 2003-10-25 16:31:15 UTC
Same problem here, but with kde-3.2-alpha2, also on ppc (gentoo, gcc-3.2.2 or 3.3.1) :
Qt: 3.2.2
KDE: 3.1.92 (alpha2, CVS >= 20030921)
KMail: 1.5.9
Trying to import the attached message from Linus with kmailcvt ends up in kmail crashing with :

kmail: WARNING: QuotedPrintableDecoder: illegally formed soft linebreak or lonely CR!
kmail: FATAL: q codec lies about it's maxDecodedSizeFor()
*** KMail got signal 6 (Crashing)

I've got quite I few other messages that make it crash in the same way, I can provide examples and backtraces if you're interested.

I don't have this problem with kde-3.1.3, haven't tested with 3.1.4.
Comment 10 Brian Waite 2003-10-27 14:55:13 UTC
That is correct. I do not have this problem with 3.1.3. I have had to keep a system running 3.1.3 just so I can get past the troublesome emails. This only occurs on 3.1.4
Comment 11 George Staikos 2003-10-27 21:54:14 UTC
I don't have HEAD on ppc yet unfortunately, sorry.  I'll try to update as soon as HEAD is stable enough for production work.  it's just not the case right now...  unless someone wants to donate a 60-80gb disk for my laptop. :)
Comment 12 Stephan Kulow 2003-10-30 15:16:16 UTC
Subject: kdepim/libkdenetwork

CVS commit by coolo: 

I think, I found the reason for "FATAL: q codec lies about it's maxDecodedSizeFor"
- well, the q coded lied about it's maxDecodedSizeFor. 
It took a diploma to figure that factories - but I managed to :)
CCMAIL: 65615-done@bugs.kde.org
CCMAIL: mutz@kde.org

Marc: I think, the real bug (and the fact it happened that often on ppc) was
in kmime_util.cpp, where one too many assumption about the signedness of char
happens ;(


  M +29 -5     kmime_codec_qp.cpp   1.13
  M +4 -20     kmime_codec_qp.h   1.5


--- kdepim/libkdenetwork/kmime_codec_qp.cpp  #1.12:1.13
@@ -190,4 +190,18 @@ public:
 };
 
+// this doesn't access any member variables, so it can be defined static
+// but then we can't call it from virtual functions
+static int QuotedPrintableDecoder_maxDecodedSizeFor( int insize, bool withCRLF ) {
+  // all chars unencoded:
+  int result = insize;
+  // but maybe all of them are \n and we need to make them \r\n :-o
+  if ( withCRLF )
+    result += insize;
+
+  // there might be an accu plus escape
+  result += 2;
+
+  return result;
+}
 
 Encoder * QuotedPrintableCodec::makeEncoder( bool withCRLF ) const {
@@ -199,4 +213,8 @@ Decoder * QuotedPrintableCodec::makeDeco
 }
 
+int QuotedPrintableCodec::maxDecodedSizeFor( int insize, bool withCRLF ) const {
+    return QuotedPrintableDecoder_maxDecodedSizeFor(insize, withCRLF);
+}
+
 Encoder * Rfc2047QEncodingCodec::makeEncoder( bool withCRLF ) const {
   return new Rfc2047QEncodingEncoder( withCRLF );
@@ -207,4 +225,8 @@ Decoder * Rfc2047QEncodingCodec::makeDec
 }
 
+int Rfc2047QEncodingCodec::maxDecodedSizeFor( int insize, bool withCRLF ) const {
+    return QuotedPrintableDecoder_maxDecodedSizeFor(insize, withCRLF);
+}
+
 Encoder * Rfc2231EncodingCodec::makeEncoder( bool withCRLF ) const {
   return new Rfc2047QEncodingEncoder( withCRLF, '%' );
@@ -215,4 +237,7 @@ Decoder * Rfc2231EncodingCodec::makeDeco
 }
 
+int Rfc2231EncodingCodec::maxDecodedSizeFor( int insize, bool withCRLF ) const {
+    return QuotedPrintableDecoder_maxDecodedSizeFor(insize, withCRLF);
+}
 
   /********************************************************/

--- kdepim/libkdenetwork/kmime_codec_qp.h  #1.4:1.5
@@ -59,13 +59,5 @@ public:
   }
 
-  int maxDecodedSizeFor( int insize, bool withCRLF=false ) const {
-    // all chars unencoded:
-    int result = insize;
-    // but maybe all of them are \n and we need to make them \r\n :-o
-    if ( withCRLF )
-      result += insize;
-
-    return result;
-  }
+  int maxDecodedSizeFor( int insize, bool withCRLF=false ) const;
 
   Encoder * makeEncoder( bool withCRLF=false ) const;
@@ -93,9 +85,5 @@ public:
   }
 
-  int maxDecodedSizeFor( int insize, bool withCRLF=false ) const {
-    (void)withCRLF; // keep compiler happy
-    // equally simple: nothing is encoded at all, so:
-    return insize;
-  }
+  int maxDecodedSizeFor( int insize, bool withCRLF=false ) const;
 
   Encoder * makeEncoder( bool withCRLF=false ) const;
@@ -122,9 +110,5 @@ public:
   }
 
-  int maxDecodedSizeFor( int insize, bool withCRLF=false ) const {
-    (void)withCRLF; // keep compiler happy
-    // same as for "q" encoding:
-    return insize;
-  }
+  int maxDecodedSizeFor( int insize, bool withCRLF=false ) const;
 
   Encoder * makeEncoder( bool withCRLF=false ) const;


Comment 13 Vincent Strubel 2003-11-04 10:42:59 UTC
Ok, I applied the above patch to 3.2_beta1, it seems to do the trick. I had to move all my mails to .txt files and reimport them (otherwise they would all be display with chinese characters whatever the charset), and then all the ancient mails that made kmail crash could be read without a problem.
Thanks a lot !
Comment 14 Stephan Kulow 2003-11-04 11:11:45 UTC
you just have to remove the index files. They were corrupted by another bug.
Comment 15 Ingo Klöcker 2003-11-20 00:08:20 UTC
*** Bug 68560 has been marked as a duplicate of this bug. ***
Comment 16 Stephan Kulow 2003-11-22 10:01:38 UTC
*** Bug 68750 has been marked as a duplicate of this bug. ***
Comment 17 Stephan Kulow 2003-11-22 10:02:03 UTC
*** Bug 66640 has been marked as a duplicate of this bug. ***
Comment 18 Stephan Kulow 2003-12-08 10:59:47 UTC
*** Bug 69826 has been marked as a duplicate of this bug. ***
Comment 19 Stephan Kulow 2004-02-12 17:38:55 UTC
*** Bug 75073 has been marked as a duplicate of this bug. ***