diff options
| author | luqiuwen <[email protected]> | 2019-01-05 18:17:47 +0600 |
|---|---|---|
| committer | luqiuwen <[email protected]> | 2019-01-05 18:17:47 +0600 |
| commit | a91feaf7edd616a8fa0ca02c7c906cf74652619a (patch) | |
| tree | f6fde7ce2e9e5e7060332150b87d155c9d9625a1 | |
| parent | 43646e60be098a94592a5c87b57f07b71b67f1a4 (diff) | |
Close #106 修正当命中关键字阻断时,在发送现场文件处Coredump的问题
* 原实现在命中应答关键字时,认为BODY_BEGIN时已经创建过evbuffer,直接使用
* 现修正,当evbuf为空时,创建evbuffer.
| -rw-r--r-- | plugin/business/pangu-http/src/pangu_http.cpp | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/plugin/business/pangu-http/src/pangu_http.cpp b/plugin/business/pangu-http/src/pangu_http.cpp index ff9bd9c..33b44eb 100644 --- a/plugin/business/pangu-http/src/pangu_http.cpp +++ b/plugin/business/pangu-http/src/pangu_http.cpp @@ -1152,25 +1152,26 @@ void enforce_control_policy(const struct tfe_stream * stream, const struct tfe_h default: assert(0); break; } - if(ctx->action!=PG_ACTION_NONE && ctx->action!=PG_ACTION_WHITELIST) + + /* Don't store reqeust/response body when NOT hit or hit whitelist */ + if(ctx->action == PG_ACTION_NONE || ctx->action == PG_ACTION_WHITELIST) { - if (events & EV_HTTP_REQ_BODY_BEGIN) - { - ctx->log_req_body=evbuffer_new(); - } - if (events & EV_HTTP_RESP_BODY_BEGIN) - { - ctx->log_resp_body=evbuffer_new(); - } - if(events & EV_HTTP_REQ_BODY_CONT) - { - evbuffer_add(ctx->log_req_body, body_frag, frag_size); - } - if(events & EV_HTTP_RESP_BODY_CONT) - { - evbuffer_add(ctx->log_resp_body, body_frag, frag_size); - } + return; + } + + /* Otherwise, store body */ + if(events & EV_HTTP_REQ_BODY_CONT) + { + if(ctx->log_req_body == NULL) ctx->log_req_body = evbuffer_new(); + evbuffer_add(ctx->log_req_body, body_frag, frag_size); } + + if(events & EV_HTTP_RESP_BODY_CONT) + { + if(ctx->log_resp_body == NULL) ctx->log_resp_body = evbuffer_new(); + evbuffer_add(ctx->log_resp_body, body_frag, frag_size); + } + return; } #define RESUMED_CB_NO_MORE_CALLS 0 |
