Bug 2838 - NULL-ptr segfault with special plugin configuration
Summary: NULL-ptr segfault with special plugin configuration
Status: RESOLVED FIXED
Alias: None
Product: Claws Mail (GTK 2)
Classification: Unclassified
Component: Plugins/ClamAV (show other bugs)
Version: 3.9.0
Hardware: PC Linux
: P3 major
Assignee: users
URL:
Depends on:
Blocks:
 
Reported: 2012-12-15 21:46 UTC by Michael Schwendt
Modified: 2012-12-16 13:06 UTC (History)
1 user (show)

See Also:


Attachments
one basic way to fix it (524 bytes, patch)
2012-12-15 21:46 UTC, Michael Schwendt
no flags Details | Diff

Description Michael Schwendt 2012-12-15 21:46:35 UTC
Created attachment 1209 [details]
one basic way to fix it

Claws Mail 3.9.0, plugin clamd 3.5.5

It's possible to make Claws Mail crash always upon opening the Clamav Plugin Preferences after having fiddled with the plugin configuration.

Steps to reproduce:

1. in clawsrc remove all entries in [ClamAV] section
2. start Claws Mail
3. Load clamd plugin, if not loaded already
4. open clamd plugin preferences, enable virus checking + set clamd.conf folder
5. so far so good ;)
6. reopen clamd plugin preferences, disable virus checking
7. unload clamd plugin
8. load clamd plugin again
9. reopen clamd plugin preferences

Crash!

And it has become impossible to revisit the clamd preferences once more, as unloading/loading the plugin doesn't change a thing. Restarting Claws Mail doesn't fix it either.

In that state, clawsrc contains:

[ClamAV]
clamav_enable=0
clamav_max_size=1
clamav_recv_infected=1
clamav_save_folder=#mh/Mailbox/something
clamad_config_type=1
clamd_config_folder=/etc/clamd.d/scan.conf
clamd_host=
clamd_port=0

As one can see in the plugin source code, if clamav_enable=0, it creates a NULL clamd config ptr, which it evaluates in the plugin preferences clamav_show_config() method.
Comment 1 Michael Schwendt 2012-12-15 22:03:44 UTC
Instead of steps 7+8 (unload/load plugin), one can restart Claws Mail, too, of course.
Comment 2 Michael Rasmussen 2012-12-16 04:52:57 UTC
Hi Michael,

Thanks for your patch. I will however not commit it since your patch only fixes a symptom for a much more serious bug. I have found the bug and more or less provided the proper fix causing the crash you have discovered but it still needs some more testing before I will commit it. The bug was caused by an incomplete state where the plugin was activated before a proper configuration was completed.
Comment 3 Michael Schwendt 2012-12-16 09:15:40 UTC
That could be true. The patch was really just a hot-fix for the NULL-ptr issue for anyone else who might be interested.
Comment 4 Michael Rasmussen 2012-12-16 13:06:29 UTC
Changes related to this bug have been committed.
Please check latest CVS and update the bug accordingly.

2012-12-16 [michael]    3.5.5cvs2

        * libclamd/clamd-plugin.c
        * src/clamav_plugin.c
        * src/clamav_plugin_gtk.c
            Fix bug 2838. Numerous changes made due to
            plugin in special cases could be activated
            with an incomplete configuration.

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