From fa9635edea38401727b81e176f035a8c9d6b7bc6 Mon Sep 17 00:00:00 2001 From: Marc Fournier Date: Fri, 5 Feb 2016 15:16:09 +0100 Subject: [PATCH] write_sensu: avoid calling strlen() on variable set to NULL This fixes a segfault when no `Tag` option is set. --- src/write_sensu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/write_sensu.c b/src/write_sensu.c index 507018fd..4d0e4737 100644 --- a/src/write_sensu.c +++ b/src/write_sensu.c @@ -456,7 +456,7 @@ static char *sensu_value_to_json(struct sensu_host const *host, /* {{{ */ } // incorporate sensu tags from config if any - if (strlen(sensu_tags) != 0) { + if ((sensu_tags != NULL) && (strlen(sensu_tags) != 0)) { res = asprintf(&temp_str, "%s, %s", ret_str, sensu_tags); free(ret_str); if (res == -1) { @@ -753,7 +753,7 @@ static char *sensu_notification_to_json(struct sensu_host *host, /* {{{ */ } // incorporate sensu tags from config if any - if (strlen(sensu_tags) != 0) { + if ((sensu_tags != NULL) && (strlen(sensu_tags) != 0)) { res = asprintf(&temp_str, "%s, %s", ret_str, sensu_tags); free(ret_str); if (res == -1) { -- 2.11.0