[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-2-1' - wsd/ClientSession.cpp
Jan Holesovsky
kendy at collabora.com
Wed Sep 27 13:10:24 UTC 2017
wsd/ClientSession.cpp | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
New commits:
commit fd607d3ba878b7317b6f3efe628ed553f4531bee
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/42854
Reviewed-by: pranavk <pranavk at collabora.co.uk>
Tested-by: pranavk <pranavk at collabora.co.uk>
diff --git a/wsd/ClientSession.cpp b/wsd/ClientSession.cpp
index ce4ed3a6..b5e78b7e 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)
@@ -216,14 +222,20 @@ 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 if (tokens[0] == "savetostorage")
{
int force = 0;
- getTokenInteger(tokens[1], "force", force);
+ if (tokens.size() > 1)
+ getTokenInteger(tokens[1], "force", force);
+
if (docBroker->saveToStorage(getId(), true, "" /* This is irrelevant when success is true*/, true))
{
docBroker->broadcastMessage("commandresult: { \"command\": \"savetostorage\", \"success\": true }");
More information about the Libreoffice-commits
mailing list