TSG-18679 适配maat在使用hyperscan流式扫描时最大输入字符串长度65535
This commit is contained in:
@@ -31,6 +31,7 @@
|
||||
#include <sys/types.h>
|
||||
|
||||
#define MAX_EDIT_ZONE_NUM 64
|
||||
#define MAX_SCAN_DATA_SIZE ((1 << 16) - 1)
|
||||
|
||||
enum proxy_action //Bigger action number is prior.
|
||||
{
|
||||
@@ -1878,13 +1879,15 @@ void http_replace(const struct tfe_stream * stream, const struct tfe_http_sessio
|
||||
char * rewrite_uri = NULL;
|
||||
size_t rewrite_uri_sz=0;
|
||||
if (tfe_http_in_request(events))
|
||||
{
|
||||
if(in_req_spec->uri != NULL)
|
||||
{
|
||||
rewrite_uri_sz = execute_replace_rule(in_req_spec->uri, strlen(in_req_spec->uri),
|
||||
kZoneRequestUri, rep_ctx->rule, rep_ctx->n_rule, &rewrite_uri, 1);
|
||||
}
|
||||
if(rewrite_uri_sz>0) rep_ctx->actually_replaced=1;
|
||||
rep_ctx->replacing = tfe_http_session_request_create(to_write_sess, in_req_spec->method,
|
||||
rewrite_uri_sz >0 ? rewrite_uri : in_req_spec->uri);
|
||||
|
||||
tfe_http_session_request_set(to_write_sess, rep_ctx->replacing);
|
||||
}
|
||||
else
|
||||
@@ -2728,14 +2731,22 @@ enum proxy_action http_scan(const struct tfe_http_session * session, enum tfe_ht
|
||||
ctx->sp = maat_stream_new(g_proxy_rt->feather, table_id, ctx->scan_mid);
|
||||
}
|
||||
|
||||
const unsigned char *scan_body_frag=NULL; size_t scan_len=0;
|
||||
if (body_frag != NULL)
|
||||
{
|
||||
scan_ret = maat_stream_scan(ctx->sp, (const char *)body_frag, (int)frag_size,
|
||||
scan_body_frag = body_frag;
|
||||
while (scan_body_frag < body_frag + frag_size)
|
||||
{
|
||||
scan_len = (scan_body_frag + MAX_SCAN_DATA_SIZE < body_frag + frag_size) ? MAX_SCAN_DATA_SIZE : (body_frag + frag_size - scan_body_frag);
|
||||
|
||||
scan_ret = maat_stream_scan(ctx->sp, (const char *)scan_body_frag, scan_len,
|
||||
result + hit_cnt, MAX_SCAN_RESULT - hit_cnt, &n_hit_result, ctx->scan_mid);
|
||||
if (scan_ret == MAAT_SCAN_HIT)
|
||||
{
|
||||
hit_cnt += n_hit_result;
|
||||
}
|
||||
scan_body_frag += MAX_SCAN_DATA_SIZE;
|
||||
}
|
||||
}
|
||||
|
||||
if ((events & EV_HTTP_REQ_BODY_END) | (events & EV_HTTP_RESP_BODY_END))
|
||||
|
||||
Reference in New Issue
Block a user