aboutsummaryrefslogtreecommitdiff
path: root/sample/sample-plugins/log/log.c
diff options
context:
space:
mode:
authorGert Doering2020-09-09 12:48:37 +0200
committerGert Doering2020-09-11 19:42:22 +0200
commita61c08a2c80d95dcc2bc30ddcb9a54a462e565ed (patch)
tree8905b3d2a9ed1f0785c04fcc6885e6ea547c79e6 /sample/sample-plugins/log/log.c
parent8120e1ad4f20d4ec1fa9e191f3b15740c4aec448 (diff)
downloadopenvpn-a61c08a2c80d95dcc2bc30ddcb9a54a462e565ed.zip
openvpn-a61c08a2c80d95dcc2bc30ddcb9a54a462e565ed.tar.gz
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>
Diffstat (limited to 'sample/sample-plugins/log/log.c')
-rw-r--r--sample/sample-plugins/log/log.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/sample/sample-plugins/log/log.c b/sample/sample-plugins/log/log.c
index b5c1c3b..a782aa9 100644
--- a/sample/sample-plugins/log/log.c
+++ b/sample/sample-plugins/log/log.c
@@ -78,6 +78,11 @@ openvpn_plugin_open_v1(unsigned int *type_mask, const char *argv[], const char *
* Allocate our 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.