Bug 3150 - etpan_certificate_check() leaks memory
Summary: etpan_certificate_check() leaks memory
Status: VERIFIED FIXED
Alias: None
Product: Claws Mail (GTK 2)
Classification: Unclassified
Component: Folders/IMAP (show other bugs)
Version: 3.9.3
Hardware: PC Linux
: P3 normal
Assignee: users
URL:
Depends on:
Blocks:
 
Reported: 2014-04-20 19:07 UTC by Aleksander Mazur
Modified: 2014-04-27 08:17 UTC (History)
0 users

See Also:


Attachments

Description Aleksander Mazur 2014-04-20 19:07:37 UTC
etpan_certificate_check() allocates a temporary buffer for a copy of given certificate but doesn't seem to free it.

534         tmp.data = malloc(len);
535         memcpy(tmp.data, certificate, len);
536         tmp.size = len;

$ grep -A 11 -B 2 etpan_certificate_check claws-mail-valgrind.log 
==00:00:02:07.848 2419== 2,669 bytes in 2 blocks are definitely lost in loss record 18,288 of 18,550
==00:00:02:07.848 2419==    at 0x4006B11: malloc (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==00:00:02:07.848 2419==    by 0x822E9F9: etpan_certificate_check (imap-thread.c:534)
==00:00:02:07.848 2419==    by 0x82317B4: imap_threaded_connect_ssl (imap-thread.c:648)
==00:00:02:07.848 2419==    by 0x80E5C62: imap_session_get (imap.c:1122)
==00:00:02:07.848 2419==    by 0x80E7697: imap_scan_required (imap.c:4691)
==00:00:02:07.848 2419==    by 0x80DC8EE: folderview_check_new (folderview.c:1186)
==00:00:02:07.848 2419==    by 0x80F7032: inc_all_account_mail (inc.c:360)
==00:00:02:07.848 2419==    by 0x80F8041: defer_check_all (main.c:313)
==00:00:02:07.848 2419==    by 0x48066261: g_timeout_dispatch (gmain.c:4451)
==00:00:02:07.848 2419==    by 0x48065555: g_main_context_dispatch (gmain.c:3066)
==00:00:02:07.848 2419==    by 0x4806591F: g_main_context_iterate.isra.23 (gmain.c:3713)
==00:00:02:07.848 2419==    by 0x48065DC2: g_main_loop_run (gmain.c:3907)
==00:00:02:07.848 2419== 
--
==00:00:40:59.009 2967== 1,330 bytes in 1 blocks are definitely lost in loss record 20,045 of 20,554
==00:00:40:59.009 2967==    at 0x4006B11: malloc (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==00:00:40:59.009 2967==    by 0x822E9F9: etpan_certificate_check (imap-thread.c:534)
==00:00:40:59.009 2967==    by 0x82317B4: imap_threaded_connect_ssl (imap-thread.c:648)
==00:00:40:59.009 2967==    by 0x80E5C62: imap_session_get (imap.c:1122)
==00:00:40:59.009 2967==    by 0x80E64EC: imap_set_batch (imap.c:5440)
==00:00:40:59.009 2967==    by 0x80CE460: folder_item_set_batch (folder.c:4637)
==00:00:40:59.009 2967==    by 0x80CE526: syncronize_flags (folder.c:1953)
==00:00:40:59.009 2967==    by 0x80CF312: folder_item_scan_full (folder.c:2346)
==00:00:40:59.009 2967==    by 0x80D0F67: folder_item_scan (folder.c:2507)
==00:00:40:59.009 2967==    by 0x80DC9A6: folderview_check_new (folderview.c:1190)
==00:00:40:59.009 2967==    by 0x80F7032: inc_all_account_mail (inc.c:360)
==00:00:40:59.009 2967==    by 0x81D1AEF: toolbar_inc_all_cb (toolbar.c:2667)
==00:00:40:59.009 2967== 
--
==00:00:40:59.012 2967== 6,050 bytes in 5 blocks are definitely lost in loss record 20,362 of 20,554
==00:00:40:59.012 2967==    at 0x4006B11: malloc (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==00:00:40:59.012 2967==    by 0x822E9F9: etpan_certificate_check (imap-thread.c:534)
==00:00:40:59.012 2967==    by 0x82317B4: imap_threaded_connect_ssl (imap-thread.c:648)
==00:00:40:59.012 2967==    by 0x80E5C62: imap_session_get (imap.c:1122)
==00:00:40:59.012 2967==    by 0x80E7697: imap_scan_required (imap.c:4691)
==00:00:40:59.012 2967==    by 0x80DC8EE: folderview_check_new (folderview.c:1186)
==00:00:40:59.012 2967==    by 0x80F7032: inc_all_account_mail (inc.c:360)
==00:00:40:59.012 2967==    by 0x81D1AEF: toolbar_inc_all_cb (toolbar.c:2667)
==00:00:40:59.012 2967==    by 0x48187548: g_cclosure_marshal_VOID__VOIDv (gmarshal.c:115)
==00:00:40:59.012 2967==    by 0x48185A25: _g_closure_invoke_va (gclosure.c:840)
==00:00:40:59.012 2967==    by 0x4819FA82: g_signal_emit_valist (gsignal.c:3238)
==00:00:40:59.012 2967==    by 0x481A0B80: g_signal_emit_by_name (gsignal.c:3426)
==00:00:40:59.012 2967== 
--
==00:00:40:59.013 2967== 8,719 bytes in 7 blocks are definitely lost in loss record 20,414 of 20,554
==00:00:40:59.013 2967==    at 0x4006B11: malloc (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==00:00:40:59.013 2967==    by 0x822E9F9: etpan_certificate_check (imap-thread.c:534)
==00:00:40:59.013 2967==    by 0x82317B4: imap_threaded_connect_ssl (imap-thread.c:648)
==00:00:40:59.013 2967==    by 0x80E5C62: imap_session_get (imap.c:1122)
==00:00:40:59.013 2967==    by 0x80E7697: imap_scan_required (imap.c:4691)
==00:00:40:59.013 2967==    by 0x80DC8EE: folderview_check_new (folderview.c:1186)
==00:00:40:59.013 2967==    by 0x80F7032: inc_all_account_mail (inc.c:360)
==00:00:40:59.013 2967==    by 0x80F8041: defer_check_all (main.c:313)
==00:00:40:59.013 2967==    by 0x48066261: g_timeout_dispatch (gmain.c:4451)
==00:00:40:59.013 2967==    by 0x48065555: g_main_context_dispatch (gmain.c:3066)
==00:00:40:59.013 2967==    by 0x4806591F: g_main_context_iterate.isra.23 (gmain.c:3713)
==00:00:40:59.013 2967==    by 0x48065DC2: g_main_loop_run (gmain.c:3907)
==00:00:40:59.013 2967== 
--
==00:02:51:16.969 2406== 1,330 bytes in 1 blocks are definitely lost in loss record 19,268 of 19,698
==00:02:51:16.969 2406==    at 0x4006B11: malloc (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==00:02:51:16.970 2406==    by 0x822E9F9: etpan_certificate_check (imap-thread.c:534)
==00:02:51:16.970 2406==    by 0x82317B4: imap_threaded_connect_ssl (imap-thread.c:648)
==00:02:51:16.970 2406==    by 0x80E5C62: imap_session_get (imap.c:1122)
==00:02:51:16.970 2406==    by 0x80E64EC: imap_set_batch (imap.c:5440)
==00:02:51:16.970 2406==    by 0x80CE460: folder_item_set_batch (folder.c:4637)
==00:02:51:16.970 2406==    by 0x80CE526: syncronize_flags (folder.c:1953)
==00:02:51:16.970 2406==    by 0x80CF312: folder_item_scan_full (folder.c:2346)
==00:02:51:16.970 2406==    by 0x80D0F67: folder_item_scan (folder.c:2507)
==00:02:51:16.970 2406==    by 0x80DC9A6: folderview_check_new (folderview.c:1190)
==00:02:51:16.970 2406==    by 0x80F7032: inc_all_account_mail (inc.c:360)
==00:02:51:16.970 2406==    by 0x81D1AEF: toolbar_inc_all_cb (toolbar.c:2667)
==00:02:51:16.970 2406== 
--
==00:02:51:16.972 2406== 6,050 bytes in 5 blocks are definitely lost in loss record 19,568 of 19,698
==00:02:51:16.972 2406==    at 0x4006B11: malloc (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==00:02:51:16.972 2406==    by 0x822E9F9: etpan_certificate_check (imap-thread.c:534)
==00:02:51:16.972 2406==    by 0x82317B4: imap_threaded_connect_ssl (imap-thread.c:648)
==00:02:51:16.972 2406==    by 0x80E5C62: imap_session_get (imap.c:1122)
==00:02:51:16.972 2406==    by 0x80E7697: imap_scan_required (imap.c:4691)
==00:02:51:16.972 2406==    by 0x80DC8EE: folderview_check_new (folderview.c:1186)
==00:02:51:16.972 2406==    by 0x80F7032: inc_all_account_mail (inc.c:360)
==00:02:51:16.972 2406==    by 0x81D1AEF: toolbar_inc_all_cb (toolbar.c:2667)
==00:02:51:16.972 2406==    by 0x48187548: g_cclosure_marshal_VOID__VOIDv (gmarshal.c:115)
==00:02:51:16.972 2406==    by 0x48185A25: _g_closure_invoke_va (gclosure.c:840)
==00:02:51:16.972 2406==    by 0x4819FA82: g_signal_emit_valist (gsignal.c:3238)
==00:02:51:16.972 2406==    by 0x481A0B80: g_signal_emit_by_name (gsignal.c:3426)
==00:02:51:16.972 2406== 
--
==00:02:51:16.972 2406== 8,719 bytes in 7 blocks are definitely lost in loss record 19,610 of 19,698
==00:02:51:16.972 2406==    at 0x4006B11: malloc (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==00:02:51:16.972 2406==    by 0x822E9F9: etpan_certificate_check (imap-thread.c:534)
==00:02:51:16.972 2406==    by 0x82317B4: imap_threaded_connect_ssl (imap-thread.c:648)
==00:02:51:16.972 2406==    by 0x80E5C62: imap_session_get (imap.c:1122)
==00:02:51:16.972 2406==    by 0x80E7697: imap_scan_required (imap.c:4691)
==00:02:51:16.972 2406==    by 0x80DC8EE: folderview_check_new (folderview.c:1186)
==00:02:51:16.973 2406==    by 0x80F7032: inc_all_account_mail (inc.c:360)
==00:02:51:16.973 2406==    by 0x80F8041: defer_check_all (main.c:313)
==00:02:51:16.973 2406==    by 0x48066261: g_timeout_dispatch (gmain.c:4451)
==00:02:51:16.973 2406==    by 0x48065555: g_main_context_dispatch (gmain.c:3066)
==00:02:51:16.973 2406==    by 0x4806591F: g_main_context_iterate.isra.23 (gmain.c:3713)
==00:02:51:16.973 2406==    by 0x48065DC2: g_main_loop_run (gmain.c:3907)
==00:02:51:16.973 2406== 
==00:02:51:16.973 2406== 8,719 bytes in 7 blocks are definitely lost in loss record 19,611 of 19,698
==00:02:51:16.973 2406==    at 0x4006B11: malloc (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==00:02:51:16.973 2406==    by 0x822E9F9: etpan_certificate_check (imap-thread.c:534)
==00:02:51:16.973 2406==    by 0x82317B4: imap_threaded_connect_ssl (imap-thread.c:648)
==00:02:51:16.973 2406==    by 0x80E5C62: imap_session_get (imap.c:1122)
==00:02:51:16.973 2406==    by 0x80E7697: imap_scan_required (imap.c:4691)
==00:02:51:16.973 2406==    by 0x80DC8EE: folderview_check_new (folderview.c:1186)
==00:02:51:16.973 2406==    by 0x80F7032: inc_all_account_mail (inc.c:360)
==00:02:51:16.973 2406==    by 0x80F71F9: inc_autocheck_func (inc.c:1493)
==00:02:51:16.973 2406==    by 0x48066261: g_timeout_dispatch (gmain.c:4451)
==00:02:51:16.973 2406==    by 0x48065555: g_main_context_dispatch (gmain.c:3066)
==00:02:51:16.973 2406==    by 0x4806591F: g_main_context_iterate.isra.23 (gmain.c:3713)
==00:02:51:16.973 2406==    by 0x48065DC2: g_main_loop_run (gmain.c:3907)
==00:02:51:16.973 2406== 

claws-mail-3.9.3-1.fc20.i686
Comment 1 users 2014-04-21 08:02:04 UTC
Changes related to this bug have been committed.
Please check latest Git and update the bug accordingly.
You can also get the patch from:
http://git.claws-mail.org/

++ ChangeLog	2014-04-21 10:02:04.033851311 +0200
http://git.claws-mail.org/?p=claws.git;a=commitdiff;h=2588900ab245eec48f5ccc915b29581997038d6a
Merge: e857a07 7445f4f
Author: Colin Leroy <colin@colino.net>
Date:   Mon Apr 21 10:02:03 2014 +0200

    Merge branch 'master' of file:///home/git/claws

http://git.claws-mail.org/?p=claws.git;a=commitdiff;h=7445f4f8674ea0a02e4baff42342b0d9f7754114
Author: Colin Leroy <colin@colino.net>
Date:   Mon Apr 21 10:01:39 2014 +0200

    Fix bug #3150, "etpan_certificate_check() leaks memory"

http://git.claws-mail.org/?p=claws.git;a=commitdiff;h=46063c48ccc0d379e546946563e5047775d62640
Author: Colin Leroy <colin@colino.net>
Date:   Mon Apr 21 10:00:55 2014 +0200

    Fix bug #3148, "Logic error in claws_get_socket_name()"

http://git.claws-mail.org/?p=claws.git;a=commitdiff;h=f933992350613b35e5181fee532f1415e166fefb
Author: Colin Leroy <colin@colino.net>
Date:   Mon Apr 21 10:00:25 2014 +0200

    Fix bug #3147, "verify_folderlist_xml() leaks memory"

http://git.claws-mail.org/?p=claws.git;a=commitdiff;h=e240402b874071ffafe74aaffe60c177cb798567
Author: Colin Leroy <colin@colino.net>
Date:   Mon Apr 21 09:59:11 2014 +0200

    Fix bug #3146, "Memory corruption when deleting a message from folder"
    Reference msginfo before passing to the mark_as_read_timeout deferred
    callback.

http://git.claws-mail.org/?p=claws.git;a=commitdiff;h=f69b3bab9d66372a56e19867f458c3012aefd141
Author: Colin Leroy <colin@colino.net>
Date:   Mon Apr 21 09:57:52 2014 +0200

    Fix bug #3145, "Memory corruption in imap_disconnect_all"

Note You need to log in before you can comment on or make changes to this bug.