[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-3' - net/Socket.hpp

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Sat Mar 30 17:28:55 UTC 2019


 net/Socket.hpp |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

New commits:
commit 16d4c6180d3b2089ce5048e02abf936c396fb9dd
Author:     Michael Meeks <michael.meeks at collabora.com>
AuthorDate: Sat Mar 30 11:30:39 2019 +0000
Commit:     Andras Timar <andras.timar at collabora.com>
CommitDate: Sat Mar 30 18:28:36 2019 +0100

    Crop socket buffer removal to socket buffer size & warn.
    
    Change-Id: I734b4682941d71eee02a25aab61c8e4353a11718
    Reviewed-on: https://gerrit.libreoffice.org/69952
    Reviewed-by: Andras Timar <andras.timar at collabora.com>
    Tested-by: Andras Timar <andras.timar at collabora.com>

diff --git a/net/Socket.hpp b/net/Socket.hpp
index ce30a28c9..b42d0ebc6 100644
--- a/net/Socket.hpp
+++ b/net/Socket.hpp
@@ -863,7 +863,11 @@ public:
     /// Remove the first @count bytes from input buffer
     void eraseFirstInputBytes(size_t count)
     {
-        _inBuffer.erase(_inBuffer.begin(), _inBuffer.begin() + count);
+        size_t toErase = std::min(count, _inBuffer.size());
+        if (toErase < count)
+            LOG_ERR("#" << getFD() << ": attempted to remove: " << count << " which is > size: " << _inBuffer.size() << " clamped to " << toErase);
+        if (toErase > 0)
+            _inBuffer.erase(_inBuffer.begin(), _inBuffer.begin() + count);
     }
 
     /// Detects if we have an HTTP header in the provided message and


More information about the Libreoffice-commits mailing list