summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjames <james@e7ae566f-a301-0410-adde-c780ea21d3b5>2009-12-10 23:50:03 +0000
committerjames <james@e7ae566f-a301-0410-adde-c780ea21d3b5>2009-12-10 23:50:03 +0000
commit5bb8bfea4399117c6ec42a58991e48e9e748a62b (patch)
tree15d51c1440e476d629801cb36ff1c43d40b660e1
parent1852709cd5093995f97ba4860d1a6083c6df6d6c (diff)
downloadopenvpn-5bb8bfea4399117c6ec42a58991e48e9e748a62b.tar.gz
openvpn-5bb8bfea4399117c6ec42a58991e48e9e748a62b.tar.xz
openvpn-5bb8bfea4399117c6ec42a58991e48e9e748a62b.zip
Fixed a couple issues in sample plugins auth-pam.c and down-root.c:
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
-rw-r--r--plugin/auth-pam/auth-pam.c4
-rw-r--r--plugin/down-root/down-root.c4
2 files changed, 6 insertions, 2 deletions
diff --git a/plugin/auth-pam/auth-pam.c b/plugin/auth-pam/auth-pam.c
index 52c62db..b029f85 100644
--- a/plugin/auth-pam/auth-pam.c
+++ b/plugin/auth-pam/auth-pam.c
@@ -305,6 +305,8 @@ openvpn_plugin_open_v1 (unsigned int *type_mask, const char *argv[], const char
* Allocate our context
*/
context = (struct auth_pam_context *) calloc (1, sizeof (struct auth_pam_context));
+ if (!context)
+ goto error;
context->foreground_fd = -1;
/*
@@ -492,7 +494,7 @@ openvpn_plugin_abort_v1 (openvpn_plugin_handle_t handle)
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);
diff --git a/plugin/down-root/down-root.c b/plugin/down-root/down-root.c
index 5e0c002..7cf8f18 100644
--- a/plugin/down-root/down-root.c
+++ b/plugin/down-root/down-root.c
@@ -274,6 +274,8 @@ openvpn_plugin_open_v1 (unsigned int *type_mask, const char *argv[], const char
* Allocate our context
*/
context = (struct down_root_context *) calloc (1, sizeof (struct down_root_context));
+ if (!context)
+ goto error;
context->foreground_fd = -1;
/*
@@ -434,7 +436,7 @@ openvpn_plugin_abort_v1 (openvpn_plugin_handle_t handle)
{
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);