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

See Also:

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

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Schwendt 2012-12-15 22:46:35 CET
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


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:


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 23:03:44 CET
Instead of steps 7+8 (unload/load plugin), one can restart Claws Mail, too, of course.
Comment 2 Michael Rasmussen 2012-12-16 05:52:57 CET
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 10:15:40 CET
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 14:06:29 CET
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.