Uploaded image for project: 'ZABBIX BUGS AND ISSUES'
  1. ZABBIX BUGS AND ISSUES
  2. ZBX-11959

Memory leak in agent if built on OpenBSD

XMLWordPrintable

    • Icon: Incident report Incident report
    • Resolution: Fixed
    • Icon: Minor Minor
    • 3.4.0alpha1
    • 2.2.17, 3.0.8, 3.2.4, 3.4.0alpha1
    • Agent (G)
    • 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

            Unassigned Unassigned
            abs Andrea Biscuola (Inactive)
            Team C
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: