Bug 127095

Summary: kmail crashes when viewing mails with ics attachments sent from a mac
Product: [Unmaintained] kmail Reporter: Mads D. Kristensen <madsdk>
Component: generalAssignee: kdepim bugs <kdepim-bugs>
Status: RESOLVED FIXED    
Severity: crash    
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Gentoo Packages   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: This is one example of a mail that crashes kmail

Description Mads D. Kristensen 2006-05-10 18:29:04 UTC
Version:            (using KDE KDE 3.5.1)
Installed from:    Gentoo Packages
Compiler:          gcc 3.3.6 flags: -O2 -march=pentium4 -pipe
OS:                Linux

When I receive a mail sent from a Machintosh computer with an attached .ics file kmail crashes when trying to view this mail. 

The mail is sent using Mail version 2.0.7 and Ical version 2.0.3. I have attached the mail to this bug report, so that you may try to reproduce the bug.
Comment 1 Mads D. Kristensen 2006-05-10 18:30:32 UTC
Created attachment 16009 [details]
This is one example of a mail that crashes kmail

A bad mail :-)
Comment 2 Bram Schoenmakers 2006-05-10 21:38:35 UTC
Could you provide us a backtrace?
Comment 3 Martin Koller 2006-10-28 23:36:19 UTC
I can reproduce it with KDE-3.5.5. BT:
Using host libthread_db library "/lib/tls/libthread_db.so.1".
[KCrash handler]
#9  0x4102e8db in strlen () from /lib/tls/libc.so.6
#10 0x40d459a2 in internalLatin1ToUnicode ()
   from /usr/lib/qt3/lib/libqt-mt.so.3
#11 0x40d46b80 in QString::QString () from /usr/lib/qt3/lib/libqt-mt.so.3
#12 0x4185df36 in KCal::ICalFormatImpl::readAttachment ()
   from /opt/kde3/lib/libkcal.so.2
#13 0x4185e0ee in KCal::ICalFormatImpl::readAlarm ()
   from /opt/kde3/lib/libkcal.so.2
#14 0x4185f0e9 in KCal::ICalFormatImpl::readIncidence ()
   from /opt/kde3/lib/libkcal.so.2
#15 0x4186034d in KCal::ICalFormatImpl::readEvent ()
   from /opt/kde3/lib/libkcal.so.2
#16 0x4185892b in KCal::ICalFormat::parseScheduleMessage ()
   from /opt/kde3/lib/libkcal.so.2
#17 0x4186f301 in KCal::IncidenceFormatter::formatICalInvitation ()
   from /opt/kde3/lib/libkcal.so.2
#18 0x4346163b in (anonymous namespace)::Formatter::format ()
   from /opt/kde3/lib/kde3/libkmail_bodypartformatter_text_calendar.so
#19 0x4039b151 in KMail::ObjectTreeParser::parseObjectTree ()
   from /opt/kde3/lib/libkmailprivate.so
#20 0x4039b76c in KMail::ObjectTreeParser::stdChildHandling ()
   from /opt/kde3/lib/libkmailprivate.so
#21 0x4039ba8d in KMail::ObjectTreeParser::processMultiPartMixedSubtype ()
   from /opt/kde3/lib/libkmailprivate.so
#22 0x403a370b in (anonymous namespace)::MultiPartMixedBodyPartFormatter::process () from /opt/kde3/lib/libkmailprivate.so
#23 0x4039b478 in KMail::ObjectTreeParser::parseObjectTree ()
   from /opt/kde3/lib/libkmailprivate.so
#24 0x40262db9 in KMReaderWin::parseMsg ()
   from /opt/kde3/lib/libkmailprivate.so
#25 0x4025b6c3 in KMReaderWin::displayMessage ()
   from /opt/kde3/lib/libkmailprivate.so
#26 0x4025b85d in KMReaderWin::updateReaderWin ()
   from /opt/kde3/lib/libkmailprivate.so
#27 0x4025f7d0 in KMReaderWin::qt_invoke ()
   from /opt/kde3/lib/libkmailprivate.so
#28 0x40a56c9e in QObject::activate_signal ()
   from /usr/lib/qt3/lib/libqt-mt.so.3
#29 0x40a57446 in QObject::activate_signal ()
   from /usr/lib/qt3/lib/libqt-mt.so.3
#30 0x40db2e29 in QTimer::timeout () from /usr/lib/qt3/lib/libqt-mt.so.3
#31 0x40a7be9f in QTimer::event () from /usr/lib/qt3/lib/libqt-mt.so.3
#32 0x409f367f in QApplication::internalNotify ()
   from /usr/lib/qt3/lib/libqt-mt.so.3
#33 0x409f5263 in QApplication::notify () from /usr/lib/qt3/lib/libqt-mt.so.3
#34 0x407022e1 in KApplication::notify () from /opt/kde3/lib/libkdecore.so.4
#35 0x409e7cbc in QEventLoop::activateTimers ()
   from /usr/lib/qt3/lib/libqt-mt.so.3
#36 0x409a01d9 in QEventLoop::processEvents ()
   from /usr/lib/qt3/lib/libqt-mt.so.3
#37 0x40a0b441 in QEventLoop::enterLoop () from /usr/lib/qt3/lib/libqt-mt.so.3
#38 0x40a0b286 in QEventLoop::exec () from /usr/lib/qt3/lib/libqt-mt.so.3
#39 0x409f512f in QApplication::exec () from /usr/lib/qt3/lib/libqt-mt.so.3
#40 0x0804a6a6 in main ()
Comment 4 Martin Koller 2006-10-30 20:20:59 UTC
SVN commit 600496 by mkoller:

BUG: 127095
BUG: 88840

When parsing an ATTACH;VALUE=URI: element, take care of casting
to the right datatype



 M  +15 -8     icalformatimpl.cpp  


--- branches/KDE/3.5/kdepim/libkcal/icalformatimpl.cpp #600495:600496
@@ -1183,19 +1183,26 @@
 
 Attachment *ICalFormatImpl::readAttachment(icalproperty *attach)
 {
-  icalattach *a = icalproperty_get_attach(attach);
-
   Attachment *attachment = 0;
 
-  int isurl = icalattach_get_is_url (a);
-  if (isurl == 0)
-    attachment = new Attachment((const char*)icalattach_get_data(a));
-  else {
-    attachment = new Attachment(QString(icalattach_get_url(a)));
+  icalvalue_kind value_kind = icalvalue_isa(icalproperty_get_value(attach));
+
+  if ( value_kind == ICAL_ATTACH_VALUE ) {
+    icalattach *a = icalproperty_get_attach(attach);
+
+    int isurl = icalattach_get_is_url (a);
+    if (isurl == 0)
+      attachment = new Attachment((const char*)icalattach_get_data(a));
+    else {
+      attachment = new Attachment(QString(icalattach_get_url(a)));
+    }
   }
+  else if ( value_kind == ICAL_URI_VALUE ) {
+    attachment = new Attachment(QString(icalvalue_get_uri(icalproperty_get_value(attach))));
+  }
 
   icalparameter *p = icalproperty_get_first_parameter(attach, ICAL_FMTTYPE_PARAMETER);
-  if (p)
+  if (p && attachment)
     attachment->setMimeType(QString(icalparameter_get_fmttype(p)));
 
   return attachment;