mirror of
https://github.com/OpenVPN/openvpn.git
synced 2025-05-09 21:51:05 +08:00
Handle NULL returns from calloc() in sample plugins.
This is basic housekeeping, adding NULL checks to context initialization of the sample plugin collection which are missing it. Realistically, this can never happen, but since these are supposed to be "good examples", not checking calloc() return isn't one. Trac: #587 Reported-By: Dogbert (in Trac) Signed-off-by: Gert Doering <gert@greenie.muc.de> Acked-by: David Sommerseth <davids@openvpn.net> Message-Id: <20200909104837.6123-1-gert@greenie.muc.de> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20922.html Signed-off-by: Gert Doering <gert@greenie.muc.de> (cherry picked from commit a61c08a2c80d95dcc2bc30ddcb9a54a462e565ed)
This commit is contained in:
parent
9481cca682
commit
2b8dda6911
@ -141,6 +141,11 @@ openvpn_plugin_open_v1(unsigned int *type_mask, const char *argv[], const char *
|
|||||||
* Allocate our context
|
* Allocate our context
|
||||||
*/
|
*/
|
||||||
context = (struct plugin_context *) calloc(1, sizeof(struct plugin_context));
|
context = (struct plugin_context *) calloc(1, sizeof(struct plugin_context));
|
||||||
|
if (context == NULL)
|
||||||
|
{
|
||||||
|
printf("PLUGIN: allocating memory for context failed\n");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
context->test_deferred_auth = atoi_null0(get_env("test_deferred_auth", envp));
|
context->test_deferred_auth = atoi_null0(get_env("test_deferred_auth", envp));
|
||||||
printf("TEST_DEFERRED_AUTH %d\n", context->test_deferred_auth);
|
printf("TEST_DEFERRED_AUTH %d\n", context->test_deferred_auth);
|
||||||
|
@ -94,6 +94,12 @@ openvpn_plugin_open_v3(const int version,
|
|||||||
{
|
{
|
||||||
struct plugin *plugin = calloc(1, sizeof(*plugin));
|
struct plugin *plugin = calloc(1, sizeof(*plugin));
|
||||||
|
|
||||||
|
if (plugin == NULL)
|
||||||
|
{
|
||||||
|
printf("PLUGIN: allocating memory for context failed\n");
|
||||||
|
return OPENVPN_PLUGIN_FUNC_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
plugin->type = get_env("remote_1", args->envp) ? CLIENT : SERVER;
|
plugin->type = get_env("remote_1", args->envp) ? CLIENT : SERVER;
|
||||||
plugin->log = args->callbacks->plugin_log;
|
plugin->log = args->callbacks->plugin_log;
|
||||||
|
|
||||||
|
@ -78,6 +78,11 @@ openvpn_plugin_open_v1(unsigned int *type_mask, const char *argv[], const char *
|
|||||||
* Allocate our context
|
* Allocate our context
|
||||||
*/
|
*/
|
||||||
context = (struct plugin_context *) calloc(1, sizeof(struct plugin_context));
|
context = (struct plugin_context *) calloc(1, sizeof(struct plugin_context));
|
||||||
|
if (context == NULL)
|
||||||
|
{
|
||||||
|
printf("PLUGIN: allocating memory for context failed\n");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set the username/password we will require.
|
* Set the username/password we will require.
|
||||||
|
@ -115,6 +115,11 @@ openvpn_plugin_open_v3(const int v3structver,
|
|||||||
|
|
||||||
/* Allocate our context */
|
/* Allocate our context */
|
||||||
context = (struct plugin_context *) calloc(1, sizeof(struct plugin_context));
|
context = (struct plugin_context *) calloc(1, sizeof(struct plugin_context));
|
||||||
|
if (context == NULL)
|
||||||
|
{
|
||||||
|
printf("PLUGIN: allocating memory for context failed\n");
|
||||||
|
return OPENVPN_PLUGIN_FUNC_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
/* Set the username/password we will require. */
|
/* Set the username/password we will require. */
|
||||||
context->username = "foo";
|
context->username = "foo";
|
||||||
|
@ -80,6 +80,11 @@ openvpn_plugin_open_v1(unsigned int *type_mask, const char *argv[], const char *
|
|||||||
* Allocate our context
|
* Allocate our context
|
||||||
*/
|
*/
|
||||||
context = (struct plugin_context *) calloc(1, sizeof(struct plugin_context));
|
context = (struct plugin_context *) calloc(1, sizeof(struct plugin_context));
|
||||||
|
if (context == NULL)
|
||||||
|
{
|
||||||
|
printf("PLUGIN: allocating memory for context failed\n");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set the username/password we will require.
|
* Set the username/password we will require.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user