From e6a160093a64733c581e80feebd1e9acb0ac765e Mon Sep 17 00:00:00 2001 From: Wiebe Cazemier Date: Sun, 1 May 2022 17:31:17 +0200 Subject: [PATCH] Protect against circular buffer overflow --- cirbuf.cpp | 5 +++++ 1 file changed, 5 insertions(+), 0 deletions(-) diff --git a/cirbuf.cpp b/cirbuf.cpp index d451c34..56a015c 100644 --- a/cirbuf.cpp +++ b/cirbuf.cpp @@ -110,6 +110,11 @@ void CirBuf::ensureFreeSpace(size_t n, const size_t max) if (n <= freeSpace()) return; + if (size >= 2147483648) + { + throw std::runtime_error("Trying to exceed circular buffer beyond its 2 GB limit."); + } + const size_t _usedBytes = usedBytes(); int mul = 1; -- libgit2 0.21.4