free_plugin_info(struct plugin_info *info)
{
free(info->path);
- free(info->options);
free(info->symbol_name);
+ if (info->options != NULL) {
+ int i = 0;
+ while (info->options[i] != NULL)
+ free(info->options[i++]);
+ free(info->options);
+ }
free(info);
}
/*
* If no policy plugin, fall back to the default (sudoers).
- * If there is also no I/O log plugin, sudoers for that too.
+ * If there is also no I/O log plugin, use sudoers for that too.
*/
if (policy_plugin->handle == NULL) {
/* Default policy plugin */
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
goto done;
}
- info->symbol_name = "sudoers_policy";
- info->path = SUDOERS_PLUGIN;
+ info->symbol_name = strdup("sudoers_policy");
+ info->path = strdup(SUDOERS_PLUGIN);
+ if (info->symbol_name == NULL || info->path == NULL) {
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
+ goto done;
+ }
/* info->options = NULL; */
ret = sudo_load_plugin(policy_plugin, io_plugins, info);
- free(info);
+ free_plugin_info(info);
if (!ret)
goto done;
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
goto done;
}
- info->symbol_name = "sudoers_io";
- info->path = SUDOERS_PLUGIN;
+ info->symbol_name = strdup("sudoers_io");
+ info->path = strdup(SUDOERS_PLUGIN);
+ if (info->symbol_name == NULL || info->path == NULL) {
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
+ goto done;
+ }
/* info->options = NULL; */
ret = sudo_load_plugin(policy_plugin, io_plugins, info);
- free(info);
+ free_plugin_info(info);
if (!ret)
goto done;
}
int error);
static int iolog_show_version(struct plugin_container *plugin, int verbose);
static void iolog_unlink(struct plugin_container *plugin);
+static void free_plugin_container(struct plugin_container *plugin, bool ioplugin);
__dso_public int main(int argc, char *argv[], char *envp[]);
}
/* Remove from io_plugins list and free. */
TAILQ_REMOVE(&io_plugins, plugin, entries);
+ free_plugin_container(plugin, true);
+
+ debug_return;
+}
+
+static void
+free_plugin_container(struct plugin_container *plugin, bool ioplugin)
+{
+ debug_decl(free_plugin_container, SUDO_DEBUG_PLUGIN)
+
free(plugin->path);
- free(plugin);
+ free(plugin->name);
+ if (plugin->options != NULL) {
+ int i = 0;
+ while (plugin->options[i] != NULL)
+ free(plugin->options[i++]);
+ free(plugin->options);
+ }
+ if (ioplugin)
+ free(plugin);
debug_return;
}
}
/* Free plugin structs. */
- free(policy_plugin.path);
+ free_plugin_container(&policy_plugin, false);
while ((plugin = TAILQ_FIRST(&io_plugins))) {
TAILQ_REMOVE(&io_plugins, plugin, entries);
- free(plugin->path);
- free(plugin);
+ free_plugin_container(plugin, true);
}
debug_return;