Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Duet3D/RepRapFirmware.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Crocker <dcrocker@eschertech.com>2021-07-07 10:49:53 +0300
committerDavid Crocker <dcrocker@eschertech.com>2021-07-07 10:52:23 +0300
commit32eddd9999db8ecfdca32f14e86c04b8979c31d7 (patch)
treeac5c90ca5f48cd297f0dd701f7237ad4e9b9e219
parent16a4fe9fe69b450c834bd10f0525786f7bf9c4b2 (diff)
Fixed M117 "string too long" issue
-rw-r--r--src/Configuration.h2
-rw-r--r--src/GCodes/GCodeBuffer/StringParser.cpp2
-rw-r--r--src/GCodes/GCodeQueue.cpp3
-rw-r--r--src/GCodes/GCodes2.cpp2
4 files changed, 5 insertions, 4 deletions
diff --git a/src/Configuration.h b/src/Configuration.h
index 32344a03..dd67344f 100644
--- a/src/Configuration.h
+++ b/src/Configuration.h
@@ -237,7 +237,7 @@ constexpr size_t GCodeReplyLength = StringLength256; // Maximum number of charac
constexpr size_t MachineNameLength = StringLength50;
constexpr size_t RepRapPasswordLength = StringLength20;
constexpr size_t MediumStringLength = MaxFilenameLength;
-constexpr size_t StringBufferLength = StringLength256; // Length of the string buffer used by the expression parser
+constexpr size_t M117StringLength = MediumStringLength;
constexpr size_t StringLengthLoggedCommand = StringLength100; // Length of a string buffer for a command to be logged
#if SAM4E || SAM4S || SAME70 || SAME5x || defined(ESP_NETWORKING)
diff --git a/src/GCodes/GCodeBuffer/StringParser.cpp b/src/GCodes/GCodeBuffer/StringParser.cpp
index 8b4df0f0..4c89a853 100644
--- a/src/GCodes/GCodeBuffer/StringParser.cpp
+++ b/src/GCodes/GCodeBuffer/StringParser.cpp
@@ -1278,7 +1278,7 @@ void StringParser::InternalGetQuotedString(const StringRef& str) THROWS(GCodeExc
}
else if (gb.buffer[readPointer] == c)
{
- // Two backslashes are used to represent one
+ // Two single quote characters are used to represent one
++readPointer;
}
}
diff --git a/src/GCodes/GCodeQueue.cpp b/src/GCodes/GCodeQueue.cpp
index 300ca2b8..9412e735 100644
--- a/src/GCodes/GCodeQueue.cpp
+++ b/src/GCodes/GCodeQueue.cpp
@@ -71,7 +71,8 @@ GCodeQueue::GCodeQueue() noexcept : freeItems(nullptr), queuedItems(nullptr)
case 117: // display message
{
// We need to call GetUnprecedentedString to ensure that if the string argument is not quoted, gb.DataLength() will return the correct value.
- String<1> dummy;
+ // We need to pass the correct length string buffer here because GetUnprecedentedString will throw if the string is too long for the buffer.
+ String<M117StringLength> dummy;
gb.GetUnprecedentedString(dummy.GetRef());
}
return true;
diff --git a/src/GCodes/GCodes2.cpp b/src/GCodes/GCodes2.cpp
index ebca723f..cbe9497d 100644
--- a/src/GCodes/GCodes2.cpp
+++ b/src/GCodes/GCodes2.cpp
@@ -1767,7 +1767,7 @@ bool GCodes::HandleMcode(GCodeBuffer& gb, const StringRef& reply) THROWS(GCodeEx
case 117: // Display message
{
- String<MediumStringLength> msg;
+ String<M117StringLength> msg;
gb.GetUnprecedentedString(msg.GetRef(), true);
reprap.SetMessage(msg.c_str());
}