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

New commits:
commit d3b87fc6ab869559eda8d7b3bb6577a2aa15b1cc
Author:     Michael Meeks <[email protected]>
AuthorDate: Sat Mar 30 11:30:39 2019 +0000
Commit:     Andras Timar <[email protected]>
CommitDate: Thu Jun 13 10:09:04 2019 +0200

    Crop socket buffer removal to socket buffer size & warn.
    
    Change-Id: I734b4682941d71eee02a25aab61c8e4353a11718
    Reviewed-on: https://gerrit.libreoffice.org/69951
    Reviewed-by: Andras Timar <[email protected]>
    Tested-by: Andras Timar <[email protected]>
    Reviewed-on: https://gerrit.libreoffice.org/72747

diff --git a/net/Socket.hpp b/net/Socket.hpp
index 531f5358a..2f0217d76 100644
--- a/net/Socket.hpp
+++ b/net/Socket.hpp
@@ -932,7 +932,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
_______________________________________________
Libreoffice-commits mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to