]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
http: error check htp_list_size 5464/head
authorVictor Julien <victor@inliniac.net>
Mon, 5 Oct 2020 06:17:19 +0000 (08:17 +0200)
committerVictor Julien <victor@inliniac.net>
Mon, 5 Oct 2020 06:17:25 +0000 (08:17 +0200)
This avoids a potential casting to uint64_t of -1, leading to a very
high upper bound of the tx loop.

src/app-layer-htp.c

index 8498f0730b2163b523f6f6a69d51d2c377acdb88..469fd2f1a799c63bca9735a8c76ad80e42a345e6 100644 (file)
@@ -2947,9 +2947,11 @@ static uint64_t HTPStateGetTxCnt(void *alstate)
     HtpState *http_state = (HtpState *)alstate;
 
     if (http_state != NULL && http_state->conn != NULL) {
-        const uint64_t size = (uint64_t)htp_list_size(http_state->conn->transactions);
+        const int64_t size = (int64_t)htp_list_size(http_state->conn->transactions);
+        if (size < 0)
+            return 0ULL;
         SCLogDebug("size %"PRIu64, size);
-        return size;
+        return (uint64_t)size;
     } else {
         return 0ULL;
     }