Skip to content

Use of uninitialized var in http.c #10016

Description

@braydonk

Bug Report

Describe the bug
If no compression is set, ret will be uninitialized. This whole codepath actually appears to not take into account no compression being set.

if (ctx->compress_gzip == FLB_TRUE) {
ret = flb_gzip_compress((void *) body, body_len,
&payload_buf, &payload_size);
}
else if (ctx->compress_snappy == FLB_TRUE) {
ret = flb_snappy_compress((void *) body, body_len,
&payload_buf, &payload_size);
}
else if (ctx->compress_zstd == FLB_TRUE) {
ret = flb_zstd_compress((void *) body, body_len,
&payload_buf, &payload_size);
}
if (ret == -1) {
flb_plg_warn(ctx->ins, "could not compress payload, sending as it is");
compressed = FLB_FALSE;
}
else {
compressed = FLB_TRUE;
}

This causes a crash running Fluent Bit on Windows.

To Reproduce
Run Fluent Bit with the following config:

[INPUT]
    Name dummy

[OUTPUT]
    Name http
    Match *

On Windows, the program crashes. It crashes with no message when compiled with MSVC, but debugging the program shows it is due to use of uninitialized ret.

Expected behavior
No crash.

Your Environment

  • Version used: Latest master
  • Configuration: See repro steps
  • Environment name and version (e.g. Kubernetes? What version?): N/A
  • Server type and version: Windows Server 2019
  • Operating System and version: Windows Server 2019
  • Filters and plugins: out_http

Additional context

#9989 is caused by the same commit.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions