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