|
|
|
|
@ -983,7 +983,7 @@ static AppLayerResult HTPHandleResponseData(Flow *f, void *htp_state, AppLayerPa
|
|
|
|
|
dp = (uint16_t)htp_tx_request_port_number(tx);
|
|
|
|
|
}
|
|
|
|
|
consumed = (uint32_t)htp_connp_res_data_consumed(hstate->connp);
|
|
|
|
|
if (bstr_cmp_c(h->value, "h2c") == 0) {
|
|
|
|
|
if (bstr_cmp_c(htp_header_value(h), "h2c") == 0) {
|
|
|
|
|
if (AppLayerProtoDetectGetProtoName(ALPROTO_HTTP2) == NULL) {
|
|
|
|
|
// if HTTP2 is disabled, keep the HTP_STREAM_STATE_TUNNEL mode
|
|
|
|
|
break;
|
|
|
|
|
@ -999,7 +999,7 @@ static AppLayerResult HTPHandleResponseData(Flow *f, void *htp_state, AppLayerPa
|
|
|
|
|
SCReturnStruct(APP_LAYER_INCOMPLETE(consumed, input_len - consumed));
|
|
|
|
|
}
|
|
|
|
|
SCReturnStruct(APP_LAYER_OK);
|
|
|
|
|
} else if (bstr_cmp_c_nocase(h->value, "WebSocket") == 0) {
|
|
|
|
|
} else if (bstr_cmp_c_nocase(htp_header_value(h), "WebSocket") == 0) {
|
|
|
|
|
if (AppLayerProtoDetectGetProtoName(ALPROTO_WEBSOCKET) == NULL) {
|
|
|
|
|
// if WS is disabled, keep the HTP_STREAM_STATE_TUNNEL mode
|
|
|
|
|
break;
|
|
|
|
|
@ -1141,8 +1141,9 @@ static int HTTPParseContentDispositionHeader(uint8_t *name, size_t name_len,
|
|
|
|
|
static int HtpRequestBodySetupMultipart(htp_tx_t *tx, HtpTxUserData *htud)
|
|
|
|
|
{
|
|
|
|
|
htp_header_t *h = (htp_header_t *)htp_tx_request_header(tx, "Content-Type");
|
|
|
|
|
if (h != NULL && bstr_len(h->value) > 0) {
|
|
|
|
|
htud->mime_state = SCMimeStateInit(bstr_ptr(h->value), (uint32_t)bstr_len(h->value));
|
|
|
|
|
if (h != NULL && htp_header_value_len(h) > 0) {
|
|
|
|
|
htud->mime_state =
|
|
|
|
|
SCMimeStateInit(htp_header_value_ptr(h), (uint32_t)htp_header_value_len(h));
|
|
|
|
|
if (htud->mime_state) {
|
|
|
|
|
htud->tsflags |= HTP_BOUNDARY_SET;
|
|
|
|
|
SCReturnInt(1);
|
|
|
|
|
@ -1362,10 +1363,11 @@ static int HtpResponseBodyHandle(HtpState *hstate, HtpTxUserData *htud,
|
|
|
|
|
|
|
|
|
|
/* try Content-Disposition header first */
|
|
|
|
|
htp_header_t *h = (htp_header_t *)htp_tx_response_header(tx, "Content-Disposition");
|
|
|
|
|
if (h != NULL && bstr_len(h->value) > 0) {
|
|
|
|
|
if (h != NULL && htp_header_value_len(h) > 0) {
|
|
|
|
|
/* parse content-disposition */
|
|
|
|
|
(void)HTTPParseContentDispositionHeader((uint8_t *)"filename=", 9,
|
|
|
|
|
(uint8_t *) bstr_ptr(h->value), bstr_len(h->value), &filename, &filename_len);
|
|
|
|
|
(uint8_t *)htp_header_value_ptr(h), htp_header_value_len(h), &filename,
|
|
|
|
|
&filename_len);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* fall back to name from the uri */
|
|
|
|
|
@ -2943,7 +2945,7 @@ static int HTPParserTest01(void)
|
|
|
|
|
htp_header_t *h = htp_table_get_index(htp_tx_request_headers(tx), 0, NULL);
|
|
|
|
|
FAIL_IF_NULL(h);
|
|
|
|
|
|
|
|
|
|
FAIL_IF(strcmp(bstr_util_strdup_to_c(h->value), "Victor/1.0"));
|
|
|
|
|
FAIL_IF(strcmp(bstr_util_strdup_to_c(htp_header_value(h)), "Victor/1.0"));
|
|
|
|
|
FAIL_IF(htp_tx_request_method_number(tx) != HTP_METHOD_POST);
|
|
|
|
|
FAIL_IF(htp_tx_request_protocol_number(tx) != HTP_PROTOCOL_V1_0);
|
|
|
|
|
|
|
|
|
|
@ -2987,7 +2989,7 @@ static int HTPParserTest01b(void)
|
|
|
|
|
htp_header_t *h = htp_table_get_index(htp_tx_request_headers(tx), 0, NULL);
|
|
|
|
|
FAIL_IF_NULL(h);
|
|
|
|
|
|
|
|
|
|
FAIL_IF(strcmp(bstr_util_strdup_to_c(h->value), "Victor/1.0"));
|
|
|
|
|
FAIL_IF(strcmp(bstr_util_strdup_to_c(htp_header_value(h)), "Victor/1.0"));
|
|
|
|
|
FAIL_IF(htp_tx_request_method_number(tx) != HTP_METHOD_POST);
|
|
|
|
|
FAIL_IF(htp_tx_request_protocol_number(tx) != HTP_PROTOCOL_V1_0);
|
|
|
|
|
|
|
|
|
|
@ -3042,7 +3044,7 @@ static int HTPParserTest01c(void)
|
|
|
|
|
htp_header_t *h = htp_table_get_index(htp_tx_request_headers(tx), 0, NULL);
|
|
|
|
|
FAIL_IF_NULL(h);
|
|
|
|
|
|
|
|
|
|
FAIL_IF(strcmp(bstr_util_strdup_to_c(h->value), "Victor/1.0"));
|
|
|
|
|
FAIL_IF(strcmp(bstr_util_strdup_to_c(htp_header_value(h)), "Victor/1.0"));
|
|
|
|
|
FAIL_IF(htp_tx_request_method_number(tx) != HTP_METHOD_POST);
|
|
|
|
|
FAIL_IF(htp_tx_request_protocol_number(tx) != HTP_PROTOCOL_V1_0);
|
|
|
|
|
|
|
|
|
|
@ -3098,7 +3100,7 @@ static int HTPParserTest01a(void)
|
|
|
|
|
htp_header_t *h = htp_table_get_index(htp_tx_request_headers(tx), 0, NULL);
|
|
|
|
|
FAIL_IF_NULL(h);
|
|
|
|
|
|
|
|
|
|
FAIL_IF(strcmp(bstr_util_strdup_to_c(h->value), "Victor/1.0"));
|
|
|
|
|
FAIL_IF(strcmp(bstr_util_strdup_to_c(htp_header_value(h)), "Victor/1.0"));
|
|
|
|
|
FAIL_IF(htp_tx_request_method_number(tx) != HTP_METHOD_POST);
|
|
|
|
|
FAIL_IF(htp_tx_request_protocol_number(tx) != HTP_PROTOCOL_V1_0);
|
|
|
|
|
|
|
|
|
|
@ -3639,11 +3641,11 @@ static int HTPParserTest10(void)
|
|
|
|
|
htp_header_t *h = htp_table_get_index(htp_tx_request_headers(tx), 0, NULL);
|
|
|
|
|
FAIL_IF_NULL(h);
|
|
|
|
|
|
|
|
|
|
char *name = bstr_util_strdup_to_c(h->name);
|
|
|
|
|
char *name = bstr_util_strdup_to_c(htp_header_name(h));
|
|
|
|
|
FAIL_IF_NULL(name);
|
|
|
|
|
FAIL_IF(strcmp(name, "Host") != 0);
|
|
|
|
|
|
|
|
|
|
char *value = bstr_util_strdup_to_c(h->value);
|
|
|
|
|
char *value = bstr_util_strdup_to_c(htp_header_value(h));
|
|
|
|
|
FAIL_IF_NULL(value);
|
|
|
|
|
FAIL_IF(strcmp(value, "www.google.com") != 0);
|
|
|
|
|
|
|
|
|
|
@ -3817,11 +3819,11 @@ static int HTPParserTest13(void)
|
|
|
|
|
htp_header_t *h = htp_table_get_index(htp_tx_request_headers(tx), 0, NULL);
|
|
|
|
|
FAIL_IF_NULL(h);
|
|
|
|
|
|
|
|
|
|
char *name = bstr_util_strdup_to_c(h->name);
|
|
|
|
|
char *name = bstr_util_strdup_to_c(htp_header_name(h));
|
|
|
|
|
FAIL_IF_NULL(name);
|
|
|
|
|
FAIL_IF(strcmp(name, "Host") != 0);
|
|
|
|
|
|
|
|
|
|
char *value = bstr_util_strdup_to_c(h->value);
|
|
|
|
|
char *value = bstr_util_strdup_to_c(htp_header_value(h));
|
|
|
|
|
FAIL_IF_NULL(value);
|
|
|
|
|
FAIL_IF(strcmp(value, "www.google.com\rName: Value") != 0);
|
|
|
|
|
|
|
|
|
|
|