From: Mark Kavanagh Date: Mon, 19 Feb 2018 15:55:45 +0000 (+0000) Subject: utils_ovs: fix potential strcmp() NULL ptr param X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=4b0f10343baca980c684c7d2978b7bea684505b0;p=collectd.git utils_ovs: fix potential strcmp() NULL ptr param YAJL_GET_STRING(array_values[0]) may return NULL if array_values[0]->string is NULL; passing a NULL parameter to strcmp() is not recommended, since the resultant behaviour may be undefined. Resolve the issue by adding a NULL check for the string returned by YAJL_GET_STRING. Fixes: cbq59d853 ("ovs_events: Fix plugin collectd config file") Signed-off-by: Mark Kavanagh --- diff --git a/src/utils_ovs.c b/src/utils_ovs.c index 0ee05e00..088ed7db 100644 --- a/src/utils_ovs.c +++ b/src/utils_ovs.c @@ -1364,7 +1364,7 @@ yajl_val ovs_utils_get_map_value(yajl_val jval, const char *key) { /* check first element of the array */ str_val = YAJL_GET_STRING(array_values[0]); - if (strcmp("map", str_val) != 0) + if (str_val == NULL || strcmp("map", str_val) != 0) return NULL; /* try to find map value by map key */