[Libreoffice-commits] online.git: 2 commits - net/FakeSocket.cpp net/Socket.hpp
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Mon Oct 29 22:51:54 UTC 2018
net/FakeSocket.cpp | 24 ++++++++++++++----------
net/Socket.hpp | 2 ++
2 files changed, 16 insertions(+), 10 deletions(-)
New commits:
commit 4ce96fb8fff164555b165f9b3692b453b8ff3660
Author: Tor Lillqvist <tml at collabora.com>
AuthorDate: Tue Oct 30 00:46:52 2018 +0200
Commit: Tor Lillqvist <tml at collabora.com>
CommitDate: Tue Oct 30 00:47:26 2018 +0200
Don't access nonexistent vector element in the EOF case
diff --git a/net/FakeSocket.cpp b/net/FakeSocket.cpp
index ecbcdc33e..0a4419110 100644
--- a/net/FakeSocket.cpp
+++ b/net/FakeSocket.cpp
@@ -510,18 +510,22 @@ ssize_t fakeSocketRead(int fd, void *buf, size_t nbytes)
return -1;
}
- // These sockets are record-oriented. It won't work to read less than the whole record in turn
- // to be read.
- ssize_t result = pair.buffer[K][0].size();
- if (nbytes < result)
+ ssize_t result = 0;
+ if (pair.buffer[K].size() > 0)
{
- loggingBuffer << "FakeSocket EAGAIN: Read from #" << fd << ", " << nbytes << (nbytes == 1 ? " byte" : " bytes") << flush();
- errno = EAGAIN; // Not the right errno, but what would be?q
- return -1;
- }
+ // These sockets are record-oriented. It won't work to read less than the whole record in
+ // turn to be read.
+ result = pair.buffer[K][0].size();
+ if (nbytes < result)
+ {
+ loggingBuffer << "FakeSocket EAGAIN: Read from #" << fd << ", " << nbytes << (nbytes == 1 ? " byte" : " bytes") << flush();
+ errno = EAGAIN; // Not the right errno, but what would be?
+ return -1;
+ }
- memmove(buf, pair.buffer[K][0].data(), result);
- pair.buffer[K].erase(pair.buffer[K].begin());
+ memmove(buf, pair.buffer[K][0].data(), result);
+ pair.buffer[K].erase(pair.buffer[K].begin());
+ }
// If peer is closed or shut down, we continue to be readable
if (pair.fd[N] == -1 || pair.shutdown[N])
commit 9fec3b0e277c6dc9a979bd2afeb07aee4a0a54c5
Author: Tor Lillqvist <tml at collabora.com>
AuthorDate: Tue Oct 30 00:45:55 2018 +0200
Commit: Tor Lillqvist <tml at collabora.com>
CommitDate: Tue Oct 30 00:47:21 2018 +0200
Handle EOF case (when fakeSocketAvailableDataLength() returns 0)
diff --git a/net/Socket.hpp b/net/Socket.hpp
index 3a28bffdd..e62b01039 100644
--- a/net/Socket.hpp
+++ b/net/Socket.hpp
@@ -893,6 +893,8 @@ public:
ssize_t len;
if (available == -1)
len = -1;
+ else if (available == 0)
+ len = 0;
else
{
std::vector<char>buf(available);
More information about the Libreoffice-commits
mailing list