output/http: log content-type like other headers

Ticket: 8056

Avoid stack allocation.
Do not handle null and ; especially

(cherry picked from commit b8411fcc8d)
pull/14298/head
Philippe Antoine 7 months ago committed by Jason Ish
parent f67d72702a
commit 4b1d284bb5

@ -237,13 +237,12 @@ static void EveHttpLogJSONBasic(JsonBuilder *js, htp_tx_t *tx)
if (tx->response_headers != NULL) {
htp_header_t *h_content_type = htp_table_get_c(tx->response_headers, "content-type");
if (h_content_type != NULL) {
const size_t size = bstr_len(h_content_type->value) * 2 + 1;
char string[size];
BytesToStringBuffer(bstr_ptr(h_content_type->value), bstr_len(h_content_type->value), string, size);
char *p = strchr(string, ';');
uint32_t len = (uint32_t)bstr_len(h_content_type->value);
const uint8_t *p = memchr(bstr_ptr(h_content_type->value), ';', len);
if (p != NULL)
*p = '\0';
jb_set_string(js, "http_content_type", string);
len = (uint32_t)(p - bstr_ptr(h_content_type->value));
jb_set_string_from_bytes(
js, "http_content_type", bstr_ptr(h_content_type->value), len);
}
htp_header_t *h_content_range = htp_table_get_c(tx->response_headers, "content-range");
if (h_content_range != NULL) {

Loading…
Cancel
Save