Bug 3148 - Logic error in claws_get_socket_name()
Summary: Logic error in claws_get_socket_name()
Status: VERIFIED FIXED
Alias: None
Product: Claws Mail
Classification: Unclassified
Component: Other (show other bugs)
Version: 3.9.3
Hardware: PC Linux
: P3 minor
Assignee: users
URL:
Depends on:
Blocks:
 
Reported: 2014-04-20 12:08 CEST by Deweloper
Modified: 2014-04-27 10:16 CEST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Deweloper 2014-04-20 12:08:48 CEST
Valgrind report for claws-mail-3.9.3-1.fc20.i686:

==00:00:00:05.490 2406== Conditional jump or move depends on uninitialised value(s)
==00:00:00:05.490 2406==    at 0x80F9858: claws_get_socket_name (main.c:2147)
==00:00:00:05.490 2406==    by 0x80F99BE: prohibit_duplicate_launch (main.c:2189)
==00:00:00:05.490 2406==    by 0x8080E2D: main (main.c:1001)

From http://git.claws-mail.org/?p=claws.git;a=tree;f=src;h=982b9ceb382ffd6ca317acdce88d15c2993576e7;hb=HEAD (line 2147 from report above is now line 2150):

2147                 if (stat(socket_dir, &st) < 0 && errno != ENOENT) {
2148                         g_print("Error stat'ing socket_dir %s: %s\n",
2149                                 socket_dir, strerror(errno));
2150                 } else if (S_ISSOCK(st.st_mode)) {

If stat() failed with errno=ENOENT, st.st_mode is being evaluated - what is wrong since whole st structure is uninitialized due to stat() failure.
Comment 1 users 2014-04-21 10:02:06 CEST
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"
Comment 2 Deweloper 2014-04-27 10:16:18 CEST
The original issue is fixed as of a9065aec26499a0e1294c73b6d9e6f039976521e, however the function leaks memory now - socket_dir is never free'd:

==00:03:04:19.263 8553== 21 bytes in 1 blocks are definitely lost in loss record 6,994 of 18,297
==00:03:04:19.263 8553==    at 0x4006B11: malloc (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==00:03:04:19.263 8553==    by 0x47DFC02F: __vasprintf_chk (vasprintf_chk.c:80)
==00:03:04:19.264 8553==    by 0x480AA58A: g_vasprintf (stdio2.h:210)
==00:03:04:19.264 8553==    by 0x480844FF: g_strdup_vprintf (gstrfuncs.c:517)
==00:03:04:19.264 8553==    by 0x48084543: g_strdup_printf (gstrfuncs.c:543)
==00:03:04:19.264 8553==    by 0x80F056F: claws_get_socket_name (main.c:2142)
==00:03:04:19.264 8553==    by 0x80F06FE: prohibit_duplicate_launch (main.c:2195)
==00:03:04:19.264 8553==    by 0x807D596: main (main.c:1002)
Comment 3 users 2014-04-27 22:06:05 CEST
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-27 22:06:04.613634529 +0200
http://git.claws-mail.org/?p=claws.git;a=commitdiff;h=8c2a33faa4743c7fe656d65efa06df40aada92e3
Merge: 0741f40 a9aae8f
Author: Colin Leroy <colin@colino.net>
Date:   Sun Apr 27 22:06:03 2014 +0200

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

http://git.claws-mail.org/?p=claws.git;a=commitdiff;h=a9aae8f1aded116587af78fa7882b213dd9908fb
Merge: 5bf6c64 6bea799
Author: Colin Leroy <colin@colino.net>
Date:   Sun Apr 27 22:05:35 2014 +0200

    Merge branch 'master' of ssh://git.claws-mail.org/home/git/claws

http://git.claws-mail.org/?p=claws.git;a=commitdiff;h=5bf6c64e0685ca577f9ea4be5a578199dd192947
Author: Colin Leroy <colin@colino.net>
Date:   Sun Apr 27 22:04:50 2014 +0200

    Fix leak (bug #3148, thanks for the heads up!)