]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
http: error check htp_list_size
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 11:57:43 +0000 (13:57 +0200)
This avoids a potential casting to uint64_t of -1, leading to a very
high upper bound of the tx loop.

(cherry picked from commit e07a4393a9dc07d199a04540d0b54119ee95a2a5)

src/app-layer-htp.c

index 664a60bb80b5213daf6105f50a8ed10e5132122d..6f2c8d26708335b72230379f3895e52014ebce3b 100644 (file)
@@ -2972,9 +2972,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;
     }