@@ -8013,6 +8013,10 @@ static int _dns_server_tcp_recv(struct dns_server_conn_tcp_client *tcpclient)
80138013 return 0 ;
80148014 }
80158015
8016+ if (unlikely (tcpclient -> recvbuff .size < 0 )) {
8017+ BUG ("recv buffer size is invalid." );
8018+ }
8019+
80168020 len = _dns_server_tcp_socket_recv (tcpclient , tcpclient -> recvbuff .buf + tcpclient -> recvbuff .size ,
80178021 sizeof (tcpclient -> recvbuff .buf ) - tcpclient -> recvbuff .size );
80188022 if (len < 0 ) {
@@ -8055,6 +8059,12 @@ static int _dns_server_tcp_process_one_request(struct dns_server_conn_tcp_client
80558059 /* Handling multiple requests */
80568060 for (;;) {
80578061 ret = RECV_ERROR_FAIL ;
8062+
8063+ if (proceed_len > tcpclient -> recvbuff .size ) {
8064+ tlog (TLOG_DEBUG , "proceed_len > recvbuff.size" );
8065+ goto out ;
8066+ }
8067+
80588068 if (tcpclient -> head .type == DNS_CONN_TYPE_HTTPS_CLIENT ) {
80598069 if ((total_len - proceed_len ) <= 0 ) {
80608070 ret = RECV_ERROR_AGAIN ;
@@ -8066,7 +8076,7 @@ static int _dns_server_tcp_process_one_request(struct dns_server_conn_tcp_client
80668076 goto out ;
80678077 }
80688078
8069- len = http_head_parse (http_head , tcpclient -> recvbuff .buf , tcpclient -> recvbuff .size );
8079+ len = http_head_parse (http_head , tcpclient -> recvbuff .buf + proceed_len , tcpclient -> recvbuff .size );
80708080 if (len < 0 ) {
80718081 if (len == -1 ) {
80728082 ret = 0 ;
@@ -8155,7 +8165,7 @@ static int _dns_server_tcp_process_one_request(struct dns_server_conn_tcp_client
81558165 request_len = ntohs (* ((unsigned short * )(request_data )));
81568166
81578167 if (request_len >= sizeof (tcpclient -> recvbuff .buf )) {
8158- tlog (TLOG_DEBUG , "request length is invalid." );
8168+ tlog (TLOG_DEBUG , "request length is invalid. len = %d" , request_len );
81598169 goto errout ;
81608170 }
81618171
0 commit comments