After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 125051 - Pan segfaults when reading a certain message
Pan segfaults when reading a certain message
Status: RESOLVED FIXED
Product: Pan
Classification: Other
Component: general
0.14.2
Other Linux
: Normal normal
: 0.14.3
Assigned To: Charles Kerr
Pan QA Team
: 126613 128877 131195 131587 131846 131878 131886 132365 132919 132928 134693 135035 135210 143252 (view as bug list)
Depends on: 116269
Blocks:
 
 
Reported: 2003-10-20 18:16 UTC by Søren Boll Overgaard
Modified: 2004-12-22 21:47 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
message causing the segfault (4.32 KB, text/plain)
2003-10-20 21:21 UTC, Christophe Lambin
Details

Description Søren Boll Overgaard 2003-10-20 18:16:18 UTC
Hi,

A debian user reported the following to the Debian BTS:

Pan segfaults when reading the message located here:
http://article.gmane.org/gmane.linux.debian.devel.project/2317

The segfault also occurs when running pan from a newly created
account. I'm attaching an bzipped archive with backtrace, strace and
the output from pan --debug.

Details are at http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=216674
Comment 1 Christophe Lambin 2003-10-20 21:19:55 UTC
Confirmed. The full backtrace is:

  • #0 memcpy
    from /lib/i686/libc.so.6
  • #1 stream_read
    at gmime-stream-mem.c line 130
  • #2 g_mime_stream_read
    at gmime-stream.c line 162
  • #3 g_mime_stream_buffer_gets
    at gmime-stream-buffer.c line 531
  • #4 stream_readln
    at util-mime.c line 414
  • #5 separate_encoded_parts
    at util-mime.c line 465
  • #6 handle_inline_encoded_data
    at util-mime.c line 735
  • #7 handle_inline_encoded_data
    at util-mime.c line 712
  • #8 pan_g_mime_parser_construct_message
    at util-mime.c line 981
  • #9 acache_get_message
    at acache.c line 841
  • #10 task_bodies_ran_cb
    at text.c line 902
  • #11 pan_callback_call
    at pan-callback.c line 63
  • #12 real_queue_remove_tasks
    at queue.c line 718
  • #13 queue_do_todo
    at queue.c line 1135
  • #14 queue_run_what_we_can
    at queue.c line 1100
  • #15 queue_mainloop
    at queue.c line 1203
  • #16 g_static_private_free
    from /usr/lib/libglib-2.0.so.0
  • #17 pthread_start_thread
    from /lib/i686/libpthread.so.0
  • #18 pthread_start_thread_event
    from /lib/i686/libpthread.so.0

Comment 2 Christophe Lambin 2003-10-20 21:21:04 UTC
Created attachment 20828 [details]
message causing the segfault
Comment 3 Christophe Lambin 2003-10-21 20:44:02 UTC
fejj: CC'ing you so you can glance over the message.  Anything 
unusual about it? Anything that could mess up GMime's parser?
Comment 4 Jeffrey Stedfast 2003-10-21 21:03:52 UTC
msg looks ok, or at least nothing obviously wrong with it is staring
me in the face.

might try syncing up with gmime's stream code from head tho, and maybe
some other stuff?

2003-08-06  Jeffrey Stedfast  <fejj@ximian.com>

	* gmime/gmime-multipart.c (g_mime_multipart_foreach): Simplified.

	* gmime/gmime-stream-cat.c (stream_read): Same here.
	(stream_write): And finally here.

	* gmime/gmime-stream-file.c (stream_read): Same.
	(stream_write): And again...

	* gmime/gmime-stream-fs.c (stream_read): Here too.
	(stream_write): And here.

	* gmime/gmime-stream-mmap.c (stream_read): Same as the mem stream.
	(stream_write): Same.

	* gmime/gmime-stream-mem.c (stream_read): Need to fix the MIN
	expresion so that both args are signed, otherwise 'len' will be
	the min if the 'bytes-left' calculation is negative.
	(stream_write): Same.


the above commit may have something to do with the crash, but I'm not
sure.

if you can get a bt with debugging symbols, perhaps that'll help.
would be especially useful to know what args are being passed to
memcpy - might be that the src or dest buffers are NULL? or out of bounds?
Comment 5 Christophe Lambin 2003-11-10 19:43:35 UTC
*** Bug 126613 has been marked as a duplicate of this bug. ***
Comment 6 Christophe Lambin 2003-12-09 18:23:36 UTC
*** Bug 128877 has been marked as a duplicate of this bug. ***
Comment 7 Christophe Lambin 2004-01-15 19:40:53 UTC
*** Bug 131587 has been marked as a duplicate of this bug. ***
Comment 8 Randy Hendry 2004-01-15 20:22:30 UTC
This is a follow-on to bug 131587 that I reported and is a duplicate 
of this bug. 
 
Jeffery's 2003-10-21 comment about syncing up with the latest gmime 
code provides a fix.  The gmime fix WRT MIN is the problem (at least 
the problem with bug 131587).  I had seen a negative number too in 
the bytes left caluclation, but didn't have time to fully debug it.  
But, grabbing the latest gmime/gmime-stream-mem.c (stream_read) 
function from the gmime project (included below) stops the crash. 
 
I had first looked at updating the whole gmime code, but it didn't 
link with pan (missing functions).  BUT, for a fix for this problem, 
just replacing the pan's current gmime stream_read function with the 
lastest will compile, link, and run without the sigsegv. 
 
Recommend that if you cannot upgrade to latest gmime, that you at 
least update this function. 
 
Randy 
 
gmime/gmime-stream-mem.c: 
 
static ssize_t 
stream_read (GMimeStream *stream, char *buf, size_t len) 
{ 
        GMimeStreamMem *mem = (GMimeStreamMem *) stream; 
        off_t bound_end; 
        ssize_t n; 
 
        g_return_val_if_fail (mem->buffer != NULL, -1); 
 
        bound_end = stream->bound_end != -1 ? stream->bound_end : 
mem->buffer->len; 
 
        n = MIN (bound_end - stream->position, (off_t) len); 
        if (n > 0) { 
                memcpy (buf, mem->buffer->data + stream->position, 
n); 
                stream->position += n; 
        } else if (n < 0) { 
                /* set errno?? */ 
                n = -1; 
        } 
 
        return n; 
} 
Comment 10 Christophe Lambin 2004-01-18 22:08:50 UTC
*** Bug 131846 has been marked as a duplicate of this bug. ***
Comment 11 Christophe Lambin 2004-01-19 06:22:10 UTC
*** Bug 131878 has been marked as a duplicate of this bug. ***
Comment 12 Christophe Lambin 2004-01-19 06:24:28 UTC
*** Bug 131886 has been marked as a duplicate of this bug. ***
Comment 13 Christophe Lambin 2004-01-19 06:25:34 UTC
*** Bug 131886 has been marked as a duplicate of this bug. ***
Comment 14 Christophe Lambin 2004-01-20 20:51:02 UTC
*** Bug 131195 has been marked as a duplicate of this bug. ***
Comment 15 Christophe Lambin 2004-01-24 06:18:49 UTC
*** Bug 132365 has been marked as a duplicate of this bug. ***
Comment 16 Christophe Lambin 2004-01-29 23:25:44 UTC
*** Bug 132919 has been marked as a duplicate of this bug. ***
Comment 17 Christophe Lambin 2004-01-30 06:57:58 UTC
*** Bug 132928 has been marked as a duplicate of this bug. ***
Comment 18 Christophe Lambin 2004-02-18 06:22:25 UTC
*** Bug 134693 has been marked as a duplicate of this bug. ***
Comment 19 Christophe Lambin 2004-02-21 09:28:08 UTC
*** Bug 135035 has been marked as a duplicate of this bug. ***
Comment 20 Christophe Lambin 2004-02-23 18:47:24 UTC
*** Bug 135210 has been marked as a duplicate of this bug. ***
Comment 21 Christophe Lambin 2004-05-29 10:15:47 UTC
*** Bug 143252 has been marked as a duplicate of this bug. ***