Make renamefile more careful.

Change-Id: If39353fc01ea48d8e0077b228a6281839dde5c87
This commit is contained in:
Michael Meeks 2019-05-23 17:55:01 +01:00
parent d79666092d
commit bf88897c47

View file

@ -217,8 +217,10 @@ bool ClientSession::_handleInput(const char *buffer, int length)
return true;
}
else if (tokens[0] == "versionrestore") {
if (tokens[1] == "prerestore") {
else if (tokens[0] == "versionrestore")
{
if (tokens.size() > 1 && tokens[1] == "prerestore")
{
// green signal to WOPI host to restore the version *after* saving
// any unsaved changes, if any, to the storage
docBroker->closeDocument("versionrestore: prerestore_ack");
@ -375,9 +377,10 @@ bool ClientSession::_handleInput(const char *buffer, int length)
else
LOG_WRN("Readonly session '" << getId() << "' trying to kill another view");
}
else if (tokens[0] == "renamefile") {
else if (tokens[0] == "renamefile")
{
std::string encodedWopiFilename;
if (!getTokenString(tokens[1], "filename", encodedWopiFilename))
if (tokens.size() < 2 || !getTokenString(tokens[1], "filename", encodedWopiFilename))
{
LOG_ERR("Bad syntax for: " << firstLine);
sendTextFrame("error: cmd=renamefile kind=syntax");