[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-cd' - wsd/ClientSession.cpp
Jan Holesovsky
kendy at collabora.com
Wed Sep 27 13:48:59 UTC 2017
wsd/ClientSession.cpp | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
New commits:
commit 5d61ef57e8953c490bc2b9985e22bb187992a52a
Author: Jan Holesovsky <kendy at collabora.com>
Date: Wed Sep 27 10:15:30 2017 +0200
Don't crash when the parameters are missing.
Change-Id: I96ace7ad7757e7e0c74dd9f361c78ecff6171a96
Reviewed-on: https://gerrit.libreoffice.org/42859
Reviewed-by: Andras Timar <andras.timar at collabora.com>
Tested-by: Andras Timar <andras.timar at collabora.com>
diff --git a/wsd/ClientSession.cpp b/wsd/ClientSession.cpp
index 033a963e..89262c7e 100644
--- a/wsd/ClientSession.cpp
+++ b/wsd/ClientSession.cpp
@@ -63,7 +63,7 @@ bool ClientSession::_handleInput(const char *buffer, int length)
{
LOG_TRC(getName() << ": handling incoming [" << getAbbreviatedMessage(buffer, length) << "].");
const std::string firstLine = getFirstLine(buffer, length);
- const auto tokens = LOOLProtocol::tokenize(firstLine.data(), firstLine.size());
+ const std::vector<std::string> tokens = LOOLProtocol::tokenize(firstLine.data(), firstLine.size());
auto docBroker = getDocumentBroker();
if (!docBroker)
@@ -83,6 +83,12 @@ bool ClientSession::_handleInput(const char *buffer, int length)
if (tokens[0] == "loolclient")
{
+ if (tokens.size() < 1)
+ {
+ sendTextFrame("error: cmd=loolclient kind=badprotocolversion");
+ return false;
+ }
+
const auto versionTuple = ParseVersion(tokens[1]);
if (std::get<0>(versionTuple) != ProtocolMajorVersionNumber ||
std::get<1>(versionTuple) != ProtocolMinorVersionNumber)
@@ -208,8 +214,12 @@ bool ClientSession::_handleInput(const char *buffer, int length)
{
int dontTerminateEdit = 1;
int dontSaveIfUnmodified = 1;
- getTokenInteger(tokens[1], "dontTerminateEdit", dontTerminateEdit);
- getTokenInteger(tokens[2], "dontSaveIfUnmodified", dontSaveIfUnmodified);
+ if (tokens.size() > 1)
+ getTokenInteger(tokens[1], "dontTerminateEdit", dontTerminateEdit);
+
+ if (tokens.size() > 2)
+ getTokenInteger(tokens[2], "dontSaveIfUnmodified", dontSaveIfUnmodified);
+
docBroker->sendUnoSave(getId(), dontTerminateEdit != 0, dontSaveIfUnmodified != 0);
}
else
More information about the Libreoffice-commits
mailing list