summaryrefslogtreecommitdiff
path: root/src/HTTP_Message_Header.c
diff options
context:
space:
mode:
authorliuxueli <[email protected]>2024-03-06 16:49:07 +0800
committerliuxueli <[email protected]>2024-03-06 16:49:07 +0800
commitb8f494c571d412e748d7cb832ae7e94c41ac8b5b (patch)
treeabe4bede047a3a62303539085d6527b0e11a5007 /src/HTTP_Message_Header.c
parent328131dcc4cb95e399fce8947507cf2a92cf1b76 (diff)
OMPUB-1170: Bugfix memory leakv2.0.19
Diffstat (limited to 'src/HTTP_Message_Header.c')
-rw-r--r--src/HTTP_Message_Header.c99
1 files changed, 57 insertions, 42 deletions
diff --git a/src/HTTP_Message_Header.c b/src/HTTP_Message_Header.c
index e890990..512ef04 100644
--- a/src/HTTP_Message_Header.c
+++ b/src/HTTP_Message_Header.c
@@ -18,8 +18,8 @@
extern http_prog_runtime_parameter_t g_http_prog_para;
/**********************************************************
- * ���ܣ���ʼ������������
- * a_http:http��������
+ * ���ܣ���ʼ������������
+ * a_http:http��������
***********************************************************/
void http_inintRegionParam(http_parser_t *cur_node, int thread_seq)
{
@@ -42,6 +42,13 @@ void http_initHttpCommonInfor( http_parser_t *a_http, int thread_seq)
a_http->packet_entity_len = 0;
a_http->acc_cont_length = 0;
+ if(a_http->last_unzip_content.buf!=NULL)
+ {
+ dictator_free(thread_seq, a_http->last_unzip_content.buf);
+ a_http->last_unzip_content.buf = NULL;
+ a_http->last_unzip_content.buflen = 0;
+ }
+
if(a_http->ungzip_handle!=NULL)
{
docanalyze_endstream(a_http->ungzip_handle);
@@ -62,8 +69,8 @@ void http_initHttpCommonInfor( http_parser_t *a_http, int thread_seq)
}
/**********************************************************
- * ���ܣ���Ӧ��Ϣ����ʱ�������Ӧ��������Ϣ��Ϣ��
- * a_http:��ǰ�ڵ㡣
+ * ���ܣ���Ӧ��Ϣ����ʱ�������Ӧ��������Ϣ��Ϣ��
+ * a_http:��ǰ�ڵ㡣
**********************************************************/
void http_resetResponseSpace(http_parser_t *a_http, int thread_seq)
{
@@ -85,7 +92,7 @@ void http_initHttpCommonInfor( http_parser_t *a_http, int thread_seq)
}
}
/**********************************************************
- * ���ܣ���ʼ����һ��http �ڵ㡣
+ * ���ܣ���ʼ����һ��http �ڵ㡣
**********************************************************/
http_parser_t *http_initHttpLinkInfor(http_stream *a_http_stream, int thread_seq, struct streaminfo *a_tcp, void *a_packet)
{
@@ -126,10 +133,10 @@ void http_initHttpCommonInfor( http_parser_t *a_http, int thread_seq)
}
/**********************************************************
- * ���ܣ�����HTTP����������
- * a_http����ǰ��������
- * curdir:tcp���ݰ��ķ��򣬱�����˫�����
- * dir����ǰ���ķ���
+ * ���ܣ�����HTTP����������
+ * a_http����ǰ��������
+ * curdir:tcp���ݰ��ķ��򣬱�����˫�����
+ * dir����ǰ���ķ���
*********************************************************/
void http_buildHttpInforLink(http_stream *a_http_stream, int thread_seq, struct streaminfo *a_tcp, void *a_packet)
{
@@ -209,14 +216,14 @@ void http_initHttpCommonInfor( http_parser_t *a_http, int thread_seq)
}
/**********************************************************
- * ���ܣ���ʼ��HTTP���ӡ�
- * curdir:tcp���ݰ��ķ��򣬱�����˫�����
- * dir����ǰ���ķ���
- * pme������������
+ * ���ܣ���ʼ��HTTP���ӡ�
+ * curdir:tcp���ݰ��ķ��򣬱�����˫�����
+ * dir����ǰ���ķ���
+ * pme������������
***********************************************************/
void http_initHttpConnection(http_stream *a_http_stream, int thread_seq, struct streaminfo *a_tcp, void *a_packet)
{
- //��������ʱ�򣬵�һ������
+ //��������ʱ�򣬵�һ������
if(0==a_http_stream->uncomplete_count)
{
a_http_stream->res_req = a_tcp->curdir;
@@ -300,9 +307,9 @@ static void http_reseaseHttpInforList(http_parser_t**a_http, UINT16 uncomplete_c
}/*http_ReseaseHttpInforList*/
/**********************************************************
- * ���ܣ��ͷŽڵ㡣
- * a_http:��ǰ�ڵ㡣
- * curdir����ǰ���ݵķ���?
+ * ���ܣ��ͷŽڵ㡣
+ * a_http:��ǰ�ڵ㡣
+ * curdir����ǰ���ݵķ���?
* delete cur_node when http_infor be proccessd over
* the different with http_releaseHttpLinkNode:http_reseaseHttpInfor is delete cur_node,and proc prev and next
**********************************************************/
@@ -317,6 +324,14 @@ static void http_reseaseHttpInforList(http_parser_t**a_http, UINT16 uncomplete_c
{
stat_field_operation(g_http_prog_para.stat_handler, g_http_prog_para.stat_field[HTTP_STAT_RELEASE], FS_OP_TYPE_ADD, 1);
}
+
+ if(cur_http_node->last_unzip_content.buf!=NULL)
+ {
+ dictator_free(thread_seq, cur_http_node->last_unzip_content.buf);
+ cur_http_node->last_unzip_content.buf = NULL;
+ cur_http_node->last_unzip_content.buflen = 0;
+ }
+
if(cur_http_node->ungzip_handle!=NULL)
{
docanalyze_endstream(cur_http_node->ungzip_handle);
@@ -611,11 +626,11 @@ uchar http_tripleMatching(http_parser_t *cur_http_node, http_stream* a_http_stre
}
/**********************************************************
- * ���ܣ�ʶ��ʼ�У�������ʼ�С�
- * cur_http_node����ǰ�����ڵ㡣
- * curdir����ǰ���ݷ���
- * is_http��http��ʼ��־λ��
- * cur_halfstream����ǰ�������ݡ�
+ * ���ܣ�ʶ��ʼ�У�������ʼ�С�
+ * cur_http_node����ǰ�����ڵ㡣
+ * curdir����ǰ���ݷ���
+ * is_http��http��ʼ��־λ��
+ * cur_halfstream����ǰ�������ݡ�
* return : HTTP_RETURN_SPAN_PACKET
***********************************************************/
uchar http_doWithStartLine(http_parser_t*cur_http_node, http_stream* a_http_stream, struct streaminfo *a_tcp, int thread_seq, void* a_packet)
@@ -673,7 +688,7 @@ uchar http_processHttpProxy(http_parser_t *a_http, http_stream *a_http_stream, s
pProxydetail->uiApendLen = a_http->url_buflen;
}
- //���������������Ϣ��
+ //���������������Ϣ��
/*user and passwd in C2S*/
if(a_http->parser.curdir==DIR_C2S)
{
@@ -737,7 +752,7 @@ uchar http_analyseHttpProxy(http_parser_t *a_http, http_stream *a_http_stream,
a_http_stream->p_stream_proxy->type = STREAM_TYPE_HTTP_PROXY;
struct proxydetail* pProxydetail = (struct proxydetail *)(a_http_stream->p_stream_proxy->pdetail);
- //������״ν���
+ //������״ν���
if(pProxydetail==NULL)
{
pProxydetail=(struct proxydetail*)dictator_malloc(thread_seq,sizeof(struct proxydetail));
@@ -763,14 +778,14 @@ uchar http_analyseHttpProxy(http_parser_t *a_http, http_stream *a_http_stream,
#endif
/**********************************************************
- * ���ܣ���ȡhttp��־��Ϊȷ����ʼ��־��׼����
- * buffer:ƴ�տ�ʼǰHTTP_START_FLAGS_LEN���ֽڵ���ʱ��������
- * offset����ǰ�������Ѵ������ݵ�ƫ������
- * method��������Ϣ������ʽ��
- * is_http:httpȷ����־λ��
- * dir����ǰ���ݵķ���
- * data����ǰ���ݡ�
- * data_len����ǰ���ݳ��ȡ�
+ * ���ܣ���ȡhttp��־��Ϊȷ����ʼ��־��׼����
+ * buffer:ƴ�տ�ʼǰHTTP_START_FLAGS_LEN���ֽڵ���ʱ��������
+ * offset����ǰ�������Ѵ������ݵ�ƫ������
+ * method��������Ϣ������ʽ��
+ * is_http:httpȷ����־λ��
+ * dir����ǰ���ݵķ���
+ * data����ǰ���ݡ�
+ * data_len����ǰ���ݳ��ȡ�
return : OK GO_BACK ERROR
***********************************************************/
uchar http_findtStartFlag(http_parser_t *cur_node, uchar curdir,struct tcpdetail *tcp_detail, int thread_seq)
@@ -778,7 +793,7 @@ uchar http_findtStartFlag(http_parser_t *cur_node, uchar curdir,struct tcpdetail
uint32 *buflen = &(cur_node->buflen);
uint32 *offset = &(cur_node->processed_offset);
uchar *method = &(cur_node->parser.method);
- //��һ������ȥ�����У��ո��Ʊ�������HTTP_START_FLAGS_LEN�ֽ�
+ //��һ������ȥ�����У��ո��Ʊ�������HTTP_START_FLAGS_LEN�ֽ�
if(0==*buflen)
{
if(tcp_detail->datalen < HTTP_START_FLAGS_LEN+*offset)
@@ -794,7 +809,7 @@ uchar http_findtStartFlag(http_parser_t *cur_node, uchar curdir,struct tcpdetail
return http_judgeHttpMethod(method, (char*)tcp_detail->pdata+*offset, curdir);
}
- //һֱ�ȹ�HTTP_START_FLAGS_LEN�ֽ�
+ //һֱ�ȹ�HTTP_START_FLAGS_LEN�ֽ�
if(0<*buflen)
{
if(tcp_detail->datalen+*buflen < HTTP_START_FLAGS_LEN+*offset && tcp_detail->datalen-*offset>0)
@@ -807,7 +822,7 @@ uchar http_findtStartFlag(http_parser_t *cur_node, uchar curdir,struct tcpdetail
}
return GO_BACK;
}
- //��־һ������buffer���棬һ������data����
+ //��־һ������buffer���棬һ������data����
cur_node->pbuf = (char*)dictator_realloc(thread_seq, cur_node->pbuf, HTTP_START_FLAGS_LEN);
memcpy((void*)(cur_node->pbuf+(*buflen)), (void*)((uchar*)tcp_detail->pdata+*offset),HTTP_START_FLAGS_LEN-*buflen);
*offset += HTTP_START_FLAGS_LEN-*buflen;
@@ -818,21 +833,21 @@ uchar http_findtStartFlag(http_parser_t *cur_node, uchar curdir,struct tcpdetail
}
/**********************************************************
- * ���ܣ�����HTTP����,���ݲ�ͬ����Ϣ��ִ�в�ͬ�IJ�����
- * a_http:http��������
- * tcp_detail����ǰtcp���ݡ�
+ * ���ܣ�����HTTP����,���ݲ�ͬ����Ϣ��ִ�в�ͬ�IJ�����
+ * a_http:http��������
+ * tcp_detail����ǰtcp���ݡ�
***********************************************************/
uchar http_analyseHttpReqResHeader(http_parser_t* a_http, http_stream* a_http_stream, struct streaminfo* a_tcp, int thread_seq, void *a_packet)
{
uchar rec = OK;
struct tcpdetail *tcp_detail = (struct tcpdetail*)a_tcp->pdetail;
- //��ʼ�з���
+ //��ʼ�з���
if(HTTP_STATE_UNKNOWN==a_http->parser.http_state)
{
- /*20170207 POST������ һ�� �� �� SP+URI������һ���� */
+ /*20170207 POST������ һ�� �� �� SP+URI������һ���� */
if(a_http->pbuf==NULL)
{
- /*delete \r\n \0 ...... GET֮ǰ�пո�*/
+ /*delete \r\n \0 ...... GET֮ǰ�пո�*/
http_deleteEmptyRow(&(a_http->processed_offset),(char*)(tcp_detail->pdata), tcp_detail->datalen);
}
rec = http_findtStartFlag(a_http, a_http_stream->res_req, tcp_detail, thread_seq);
@@ -863,7 +878,7 @@ uchar http_analyseHttpReqResHeader(http_parser_t* a_http, http_stream* a_http_st
#endif
}
- //ͷ������
+ //ͷ������
if(HTTP_REGION==a_http->parser.http_state)
{
rec = http_findAndDoWithRegion(a_http, a_http_stream, a_tcp, thread_seq, a_packet);