-
Incident report
-
Resolution: Fixed
-
Minor
-
2.2.17, 3.0.8, 3.2.4, 3.4.0alpha1
-
OpenBSD 6.1-CURRENT
-
Sprint 4
-
0.5
The standard if_nameindex() function, dynamically allocate an array of structures with informations regarding network devices.
The structure should be released once used with if_freenameindex(), this is never done:
int NET_IF_DISCOVERY(AGENT_REQUEST *request, AGENT_RESULT *result) { int i; struct zbx_json j; struct if_nameindex *interfaces; if (NULL == (interfaces = if_nameindex())) { SET_MSG_RESULT(result, zbx_dsprintf(NULL, "Cannot obtain system information: %s", zbx_strerror(errno))); return SYSINFO_RET_FAIL; } zbx_json_init(&j, ZBX_JSON_STAT_BUF_LEN); zbx_json_addarray(&j, ZBX_PROTO_TAG_DATA); for (i = 0; 0 != interfaces[i].if_index; i++) { zbx_json_addobject(&j, NULL); zbx_json_addstring(&j, "{#IFNAME}", interfaces[i].if_name, ZBX_JSON_TYPE_STRING); zbx_json_close(&j); } zbx_json_close(&j); SET_STR_RESULT(result, strdup(j.buffer)); zbx_json_free(&j); return SYSINFO_RET_OK; }
Spotted using the llvm static analyzer