Skip to content

Commit cad2476

Browse files
committed
in_forward: validate return value when ingesting data (CID 507683)
Signed-off-by: Eduardo Silva <[email protected]>
1 parent a6f9c51 commit cad2476

File tree

1 file changed

+26
-11
lines changed

1 file changed

+26
-11
lines changed

plugins/in_forward/fw_prot.c

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1113,34 +1113,49 @@ static int append_log(struct flb_input_instance *ins, struct fw_conn *conn,
11131113
struct ctrace *ctr;
11141114

11151115
if (event_type == FLB_EVENT_TYPE_LOGS) {
1116-
flb_input_log_append(conn->in,
1117-
out_tag, flb_sds_len(out_tag),
1118-
data, len);
1116+
ret = flb_input_log_append(conn->in,
1117+
out_tag, flb_sds_len(out_tag),
1118+
data, len);
1119+
if (ret != 0) {
1120+
flb_plg_error(ins, "could not append logs. ret=%d", ret);
1121+
return -1;
1122+
}
11191123

11201124
return 0;
11211125
}
11221126
else if (event_type == FLB_EVENT_TYPE_METRICS) {
11231127
ret = cmt_decode_msgpack_create(&cmt, (char *) data, len, &off);
11241128
if (ret != CMT_DECODE_MSGPACK_SUCCESS) {
1125-
flb_error("cmt_decode_msgpack_create failed. ret=%d", ret);
1129+
flb_plg_error(ins, "cmt_decode_msgpack_create failed. ret=%d", ret);
1130+
return -1;
1131+
}
1132+
1133+
ret = flb_input_metrics_append(conn->in,
1134+
out_tag, flb_sds_len(out_tag),
1135+
cmt);
1136+
if (ret != 0) {
1137+
flb_plg_error(ins, "could not append metrics. ret=%d", ret);
1138+
cmt_decode_msgpack_destroy(cmt);
11261139
return -1;
11271140
}
1128-
flb_input_metrics_append(conn->in,
1129-
out_tag, flb_sds_len(out_tag),
1130-
cmt);
11311141
cmt_decode_msgpack_destroy(cmt);
11321142
}
11331143
else if (event_type == FLB_EVENT_TYPE_TRACES) {
11341144
off = 0;
11351145
ret = ctr_decode_msgpack_create(&ctr, (char *) data, len, &off);
11361146
if (ret == -1) {
1147+
flb_error("could not decode trace message. ret=%d", ret);
11371148
return -1;
11381149
}
11391150

1140-
flb_input_trace_append(ins,
1141-
out_tag, flb_sds_len(out_tag),
1142-
ctr);
1143-
1151+
ret = flb_input_trace_append(ins,
1152+
out_tag, flb_sds_len(out_tag),
1153+
ctr);
1154+
if (ret != 0) {
1155+
flb_plg_error(ins, "could not append traces. ret=%d", ret);
1156+
ctr_decode_msgpack_destroy(ctr);
1157+
return -1;
1158+
}
11441159
ctr_decode_msgpack_destroy(ctr);
11451160
}
11461161

0 commit comments

Comments
 (0)