Skip to content

Commit

Permalink
out_kafka: Fix invalid free of the message_key
Browse files Browse the repository at this point in the history
* This would need to be free with flb_sds_destroy to account for
  the header.

* The value is owned by the properties of the output and we don't
  need to free this.

==57818== Invalid free() / delete / delete[] / realloc()
==57818==    at 0x4887B40: free (vg_replace_malloc.c:872)
==57818==    by 0x8EE5F3: flb_free (flb_mem.h:127)
==57818==    by 0x8F27A7: flb_out_kafka_destroy (kafka_config.c:243)
==57818==    by 0x8EE3F7: cb_kafka_exit (kafka.c:558)
==57818==    by 0x4D6D5B: flb_output_exit (flb_output.c:474)
==57818==    by 0x4FF65F: flb_engine_shutdown (flb_engine.c:1119)
==57818==    by 0x4FF333: flb_engine_start (flb_engine.c:1017)
==57818==    by 0x49F20B: flb_lib_worker (flb_lib.c:674)
==57818==    by 0x4F1EE57: start_thread (pthread_create.c:442)
==57818==    by 0x4F87F9B: thread_start (clone.S:79)
==57818==  Address 0x5d22850 is 16 bytes inside a block of size 24 alloc'd
==57818==    at 0x48850C8: malloc (vg_replace_malloc.c:381)
==57818==    by 0x4AD267: flb_malloc (flb_mem.h:80)
==57818==    by 0x4AD4C3: sds_alloc (flb_sds.c:41)
==57818==    by 0x4AD60F: flb_sds_create_size (flb_sds.c:93)
==57818==    by 0x5B0D3F: flb_env_var_translate (flb_env.c:180)
==57818==    by 0x4D76BF: flb_output_set_property (flb_output.c:753)
==57818==    by 0x4E869F: configure_plugins_type (flb_config.c:833)
==57818==    by 0x4E8BFF: flb_config_load_config_format (flb_config.c:941)
==57818==    by 0x489843: service_configure (fluent-bit.c:765)
==57818==    by 0x48A95B: flb_main (fluent-bit.c:1298)
==57818==    by 0x48AD47: main (fluent-bit.c:1456)

Signed-off-by: Holger Hans Peter Freyther <[email protected]>
  • Loading branch information
zecke committed Apr 1, 2024
1 parent 558e96f commit e59b35a
Showing 1 changed file with 0 additions and 4 deletions.
4 changes: 0 additions & 4 deletions plugins/out_kafka/kafka_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -239,10 +239,6 @@ int flb_out_kafka_destroy(struct flb_out_kafka *ctx)
flb_free(ctx->topic_key);
}

if (ctx->message_key) {
flb_free(ctx->message_key);
}

if (ctx->message_key_field) {
flb_free(ctx->message_key_field);
}
Expand Down

0 comments on commit e59b35a

Please sign in to comment.