Skip to content

Fix NULL dereference and memory leak in HTTP output plugin #10918

@coderabbitai

Description

@coderabbitai

Problem

Two potential issues identified in plugins/out_http/http.c:

  1. NULL dereference risk: flb_http_client() can return NULL, but the code immediately dereferences c->proxy.host without checking
  2. Memory leak on early return: When http_request() returns before append_headers(), header strings allocated by extract_headers() are leaked

Location

  • File: plugins/out_http/http.c
  • Function: http_request() (formerly http_post())
  • Lines: ~175-181 and cleanup section

Solution

  • Add NULL check after flb_http_client() call
  • Free header strings on early return path
  • Guard client destruction with NULL check

Context

Impact

  • Severity: Medium (potential crash on client creation failure)
  • Frequency: Low (depends on memory pressure/network conditions)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions