tests: internall: fuzzers: http_fuzzer: fixed connection initialization
#include <fluent-bit/flb_mem.h>
#include <fluent-bit/flb_error.h>
#include <fluent-bit/flb_socket.h>
+#include <fluent-bit/flb_connection.h>
#include <fluent-bit/flb_http_client.h>
#include "flb_fuzz_header.h"
@@ -31,10 +32,16 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
}
u = flb_upstream_create(config, "127.0.0.1", 8001, 0, NULL);
- u_conn = flb_malloc(sizeof(struct flb_connection));
- if (u_conn == NULL)
+
+ u_conn = flb_connection_create(-1,
+ FLB_CONNECTION_TYPE_TCP,
+ (void *) u,
+ NULL,
+ NULL);
+
+ if (u_conn == NULL) {
return 0;
- u_conn->upstream = u;
+ }
char *proxy = NULL;
if (GET_MOD_EQ(2,1)) {
@@ -91,7 +98,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
/* Now try the http_client_proxy_connect function. */
flb_http_client_proxy_connect(u_conn);
- flb_free(u_conn);
+ flb_connection_destroy(u_conn);
flb_upstream_destroy(u);
flb_config_exit(config);
if (uri != NULL) {
