projects
/
collectd.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
65e795a
)
write_sensu: avoid calling strlen() on variable set to NULL
author
Marc Fournier
<marc.fournier@camptocamp.com>
Fri, 5 Feb 2016 14:16:09 +0000
(15:16 +0100)
committer
Marc Fournier
<marc.fournier@camptocamp.com>
Fri, 5 Feb 2016 14:16:09 +0000
(15:16 +0100)
This fixes a segfault when no `Tag` option is set.
src/write_sensu.c
patch
|
blob
|
history
diff --git
a/src/write_sensu.c
b/src/write_sensu.c
index
507018f
..
4d0e473
100644
(file)
--- 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) {