]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
detect/http: don't set min-inspect-depth higher than setting
authorVictor Julien <vjulien@oisf.net>
Fri, 26 Nov 2021 10:05:46 +0000 (11:05 +0100)
committerVictor Julien <vjulien@oisf.net>
Tue, 7 Dec 2021 12:30:16 +0000 (13:30 +0100)
src/app-layer-htp.c

index 28b10c21d3a42c49f557c701bb5fd4ef2e1e7695..46815b5f80e5eb56468641eca9bf93efe8fff110 100644 (file)
@@ -1862,10 +1862,12 @@ end:
             if ((uint64_t)hstate->conn->in_data_counter > hstate->last_request_data_stamp &&
                 (uint64_t)hstate->conn->in_data_counter - hstate->last_request_data_stamp < (uint64_t)UINT_MAX)
             {
-                uint32_t x = (uint32_t)((uint64_t)hstate->conn->in_data_counter - hstate->last_request_data_stamp);
+                const uint32_t data_size = (uint32_t)(
+                        (uint64_t)hstate->conn->in_data_counter - hstate->last_request_data_stamp);
+                const uint32_t depth = MIN(data_size, hstate->cfg->request.inspect_min_size);
 
                 /* body still in progress, but due to min inspect size we need to inspect now */
-                StreamTcpReassemblySetMinInspectDepth(hstate->f->protoctx, STREAM_TOSERVER, x);
+                StreamTcpReassemblySetMinInspectDepth(hstate->f->protoctx, STREAM_TOSERVER, depth);
                 AppLayerParserTriggerRawStreamReassembly(hstate->f, STREAM_TOSERVER);
             }
         /* after the start of the body, disable the depth logic */
@@ -1948,10 +1950,12 @@ static int HTPCallbackResponseBodyData(htp_tx_data_t *d)
             if ((uint64_t)hstate->conn->out_data_counter > hstate->last_response_data_stamp &&
                 (uint64_t)hstate->conn->out_data_counter - hstate->last_response_data_stamp < (uint64_t)UINT_MAX)
             {
-                uint32_t x = (uint32_t)((uint64_t)hstate->conn->out_data_counter - hstate->last_response_data_stamp);
+                const uint32_t data_size = (uint32_t)((uint64_t)hstate->conn->out_data_counter -
+                                                      hstate->last_response_data_stamp);
+                const uint32_t depth = MIN(data_size, hstate->cfg->response.inspect_min_size);
 
                 /* body still in progress, but due to min inspect size we need to inspect now */
-                StreamTcpReassemblySetMinInspectDepth(hstate->f->protoctx, STREAM_TOCLIENT, x);
+                StreamTcpReassemblySetMinInspectDepth(hstate->f->protoctx, STREAM_TOCLIENT, depth);
                 AppLayerParserTriggerRawStreamReassembly(hstate->f, STREAM_TOCLIENT);
             }
         /* after the start of the body, disable the depth logic */