1. Fail gracefully rather than segfault if calloc returns NULL.
2. The openvpn_plugin_abort_v1 function can potentially be called
with handle == NULL. Add code to detect this case, and if
so, avoid dereferencing pointers derived from handle.
(Thanks to David Sommerseth for finding this bug).
git-svn-id: http://svn.openvpn.net/projects/openvpn/branches/BETA21/openvpn@5261
e7ae566f-a301-0410-adde-
c780ea21d3b5
* Allocate our context
*/
context = (struct auth_pam_context *) calloc (1, sizeof (struct auth_pam_context));
+ if (!context)
+ goto error;
context->foreground_fd = -1;
/*
struct auth_pam_context *context = (struct auth_pam_context *) handle;
/* tell background process to exit */
- if (context->foreground_fd >= 0)
+ if (context && context->foreground_fd >= 0)
{
send_control (context->foreground_fd, COMMAND_EXIT);
close (context->foreground_fd);
* Allocate our context
*/
context = (struct down_root_context *) calloc (1, sizeof (struct down_root_context));
+ if (!context)
+ goto error;
context->foreground_fd = -1;
/*
{
struct down_root_context *context = (struct down_root_context *) handle;
- if (context->foreground_fd >= 0)
+ if (context && context->foreground_fd >= 0)
{
/* tell background process to exit */
send_control (context->foreground_fd, COMMAND_EXIT);