Skip to content

Commit 8cc6da6

Browse files
committed
in_forward: fix segfault and double-free in trace path handling
- Incomplete error check: only checked ret == -1, but ctr_decode_msgpack_create() can return other error codes. When ctr is NULL on error, this caused NULL pointer dereference. - Double-free: called ctr_decode_msgpack_destroy() after successful flb_input_trace_append(), but that function takes ownership and destroys the context internally. Signed-off-by: Eduardo Silva <[email protected]>
1 parent f2dd991 commit 8cc6da6

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

plugins/in_forward/fw_prot.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1146,8 +1146,8 @@ static int append_log(struct flb_input_instance *ins, struct fw_conn *conn,
11461146
else if (event_type == FLB_EVENT_TYPE_TRACES) {
11471147
off = 0;
11481148
ret = ctr_decode_msgpack_create(&ctr, (char *) data, len, &off);
1149-
if (ret == -1) {
1150-
flb_error("could not decode trace message. ret=%d", ret);
1149+
if (ret != CTR_DECODE_MSGPACK_SUCCESS) {
1150+
flb_plg_error(ins, "could not decode trace message. ret=%d", ret);
11511151
return -1;
11521152
}
11531153

@@ -1159,7 +1159,7 @@ static int append_log(struct flb_input_instance *ins, struct fw_conn *conn,
11591159
ctr_decode_msgpack_destroy(ctr);
11601160
return -1;
11611161
}
1162-
ctr_decode_msgpack_destroy(ctr);
1162+
/* Note: flb_input_trace_append takes ownership of ctr and destroys it on success */
11631163
}
11641164

11651165
return 0;

0 commit comments

Comments
 (0)