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

Memory leak in agent if built on OpenBSD

    Details

    • Type: Incident report
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.2.17, 3.0.8, 3.2.4, 3.4.0alpha1
    • Fix Version/s: 3.4.0alpha1
    • Component/s: Agent (G)
    • Labels:
    • Environment:
      OpenBSD 6.1-CURRENT
    • Team:
      Team C
    • Sprint:
      Sprint 4
    • Story Points:
      0.5

      Description

      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

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              abs Andrea Biscuola (Inactive)
            • Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: