Skip to content

Commit c0d9184

Browse files
cosmo0920edsiper
authored andcommitted
in_splunk: Process Content-Type strictly
Signed-off-by: Hiroshi Hatake <[email protected]>
1 parent b1af4a1 commit c0d9184

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

plugins/in_splunk/splunk_prot.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ static int process_hec_payload(struct flb_splunk *ctx, struct splunk_conn *conn,
576576
header = &session->parser.headers[MK_HEADER_CONTENT_TYPE];
577577
if (header->key.data == NULL) {
578578
send_response(conn, 400, "error: header 'Content-Type' is not set\n");
579-
return -1;
579+
return -2;
580580
}
581581

582582
if (header->val.len == 16 &&
@@ -595,7 +595,7 @@ static int process_hec_payload(struct flb_splunk *ctx, struct splunk_conn *conn,
595595

596596
if (request->data.len <= 0) {
597597
send_response(conn, 400, "error: no payload found\n");
598-
return -1;
598+
return -2;
599599
}
600600

601601
header_auth = &session->parser.headers[MK_HEADER_AUTHORIZATION];
@@ -846,6 +846,13 @@ int splunk_prot_handle(struct flb_splunk *ctx, struct splunk_conn *conn,
846846
strcasecmp(uri, "/services/collector") == 0) {
847847
ret = process_hec_payload(ctx, conn, tag, session, request);
848848

849+
if (ret == -2) {
850+
flb_sds_destroy(tag);
851+
mk_mem_free(uri);
852+
853+
return -1;
854+
}
855+
849856
if (!ret) {
850857
send_json_message_response(conn, 400, "{\"text\":\"Invalid data format\",\"code\":6}");
851858
}
@@ -1162,6 +1169,8 @@ int splunk_prot_handle_ng(struct flb_http_request *request,
11621169

11631170
if (ret != 0) {
11641171
send_json_message_response_ng(response, 400, "{\"text\":\"Invalid data format\",\"code\":6}");
1172+
1173+
ret = -1;
11651174
}
11661175
else {
11671176
send_json_message_response_ng(response, 200, "{\"text\":\"Success\",\"code\":0}");

0 commit comments

Comments
 (0)