From: <svn...@op...> - 2009-04-12 18:58:28
|
Author: scriptor Date: Sun Apr 12 20:58:16 2009 New Revision: 5590 URL: http://www.opensync.org/changeset/5590 Log: ldap_plugin_finalize() seems to be provided with wrong data, sometimes. It seems, that it is called twice. If this were right, this would have the fatal consequence of double free's. This patch tries to prevent this. Modified: plugins/ldap-sync/src/ldap_plugin.c Modified: plugins/ldap-sync/src/ldap_plugin.c ============================================================================== --- plugins/ldap-sync/src/ldap_plugin.c Sun Apr 12 20:58:08 2009 (r5589) +++ plugins/ldap-sync/src/ldap_plugin.c Sun Apr 12 20:58:16 2009 (r5590) @@ -59,6 +59,10 @@ return; } + if (env->sink_envs == NULL) { + ldap_plugin_printf("%s:%i: ERROR: env->sink_envs = NULL.", __FILE__, __LINE__); + return; + } while (env->sink_envs) { sink_environment *sinkenv = env->sink_envs->data; @@ -134,6 +138,8 @@ } } + env->sink_envs = NULL; + g_free(env); } @@ -4221,8 +4227,29 @@ { plugin_environment *plugin_env = (plugin_environment *)userdata; + if (plugin_env == NULL) { + osync_trace(TRACE_ERROR, "%s:%i: ERROR: plugin_env = NULL.", __FILE__, __LINE__); + return; + } + + if (plugin_env->magic == NULL) { + osync_trace(TRACE_ERROR, "%s:%i: ERROR: plugin_env->magic = NULL.", __FILE__, __LINE__); + return; + } + + if (plugin_env->magic[0] == 0) { + osync_trace(TRACE_ERROR, "%s:%i: ERROR: plugin_env->magic = 0.", __FILE__, __LINE__); + return; + } + //Free all stuff that you have allocated here. - ldap_plugin_free_env(plugin_env); + if (!strcmp(plugin_env->magic, "plugin_env")) { + ldap_plugin_free_env(plugin_env); + } else { + osync_trace(TRACE_ERROR, "%s:%i: ERROR: plugin_env->magic is not equal to \"plugin_env\", as expected.", __FILE__, __LINE__); + osync_trace(TRACE_ERROR, "%s:%i: ERROR: plugin_env->magic = \"%s\"", __FILE__, __LINE__, plugin_env->magic); + return; + } } |