From: Mark Kavanagh Date: Mon, 19 Feb 2018 13:06:36 +0000 (+0000) Subject: ovs_events: fix potential NULL pointer dereference X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=2b719323d06bb58f23fa7c43135739d0ab0cca12;p=collectd.git ovs_events: fix potential NULL pointer dereference A potentially-NULL pointer to ovs_events_iface_info_t is defererenced by an invocation of sizeof(), within ovs_events_get_iface_info(). Move the offending line, such that it is executed after the NULL-pointer check. Fixes: f6adec45 ("ovs_events: Fix notification metadata garbage.") Signed-off-by: Mark Kavanagh --- diff --git a/src/ovs_events.c b/src/ovs_events.c index bf457fdb..ef59b4c2 100644 --- a/src/ovs_events.c +++ b/src/ovs_events.c @@ -404,14 +404,14 @@ static int ovs_events_get_iface_info(yajl_val jobject, if (!YAJL_IS_OBJECT(jobject)) return -1; - /* zero the interface info structure */ - memset(ifinfo, 0, sizeof(*ifinfo)); - /* try to find external_ids, name and link_state fields */ jexternal_ids = ovs_utils_get_value_by_key(jobject, "external_ids"); if (jexternal_ids == NULL || ifinfo == NULL) return -1; + /* zero the interface info structure */ + memset(ifinfo, 0, sizeof(*ifinfo)); + /* get iface-id from external_ids field */ jvalue = ovs_utils_get_map_value(jexternal_ids, "iface-id"); if (jvalue != NULL && YAJL_IS_STRING(jvalue))