ovs_stats_update_iface() passes a pointer to a potentially-NULL
string to sstrncpy(); this is obviously problematic.
Add a check to ensure that the relevant string is non-NULL.
Fixes:
1cc7599 ("ovs_stats plugin: Fix null dereference of "port".)
Signed-off-by: Mark Kavanagh <mark.b.kavanagh@intel.com>
ovs_stats_update_iface_ext_ids(port,
YAJL_GET_ARRAY(iface_ext_ids)->values[1]);
if (iface_uuid && YAJL_IS_ARRAY(iface_uuid) &&
- YAJL_GET_ARRAY(iface_uuid)->len == 2)
+ YAJL_GET_ARRAY(iface_uuid)->len == 2 &&
+ YAJL_GET_STRING(YAJL_GET_ARRAY(iface_uuid)->values[1]) != NULL)
sstrncpy(port->iface_uuid,
YAJL_GET_STRING(YAJL_GET_ARRAY(iface_uuid)->values[1]),
sizeof(port->iface_uuid));
+ else {
+ ERROR("ovs_stats plugin: incorrect JSON interface data");
+ return -1;
+ }
return 0;
}