From 34123b6bfc39e5bea5f2c599b1eea51d3c82ba06 Mon Sep 17 00:00:00 2001 From: dimitri staessens Date: Mon, 22 Aug 2016 16:41:35 +0200 Subject: tools: Fix segmentation faults The apis parameter is not set if the IRMd is not running when running the tool. --- src/tools/irm/irm_ipcp_bootstrap.c | 5 +++-- src/tools/irm/irm_ipcp_enroll.c | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'src/tools') diff --git a/src/tools/irm/irm_ipcp_bootstrap.c b/src/tools/irm/irm_ipcp_bootstrap.c index 34c5d223..3db43e6e 100644 --- a/src/tools/irm/irm_ipcp_bootstrap.c +++ b/src/tools/irm/irm_ipcp_bootstrap.c @@ -95,7 +95,7 @@ int do_bootstrap_ipcp(int argc, char ** argv) char * ipcp_type = NULL; char * dif_name = NULL; char * if_name = NULL; - pid_t * apis; + pid_t * apis = NULL; ssize_t len = 0; int i = 0; @@ -194,7 +194,8 @@ int do_bootstrap_ipcp(int argc, char ** argv) if (irm_bootstrap_ipcp(apis[i], &conf)) return -1; - free(apis); + if (apis != NULL) + free(apis); return 0; } diff --git a/src/tools/irm/irm_ipcp_enroll.c b/src/tools/irm/irm_ipcp_enroll.c index b7a12e2c..3755f199 100644 --- a/src/tools/irm/irm_ipcp_enroll.c +++ b/src/tools/irm/irm_ipcp_enroll.c @@ -39,7 +39,7 @@ int do_enroll_ipcp(int argc, char ** argv) { char * name = NULL; char * dif_name = NULL; - pid_t * apis; + pid_t * apis = NULL; ssize_t len = 0; int i = 0; @@ -74,7 +74,8 @@ int do_enroll_ipcp(int argc, char ** argv) if (irm_enroll_ipcp(apis[i], dif_name)) return -1; - free(apis); + if (apis != NULL) + free(apis); return 0; } -- cgit v1.2.3