Bug 1398 - Metadata Editor tag fields emptied when field length stored in project exceeds a given length

This commit is contained in:
Leland Lucius 2021-02-12 10:32:43 -06:00
parent 0c234359af
commit 7547de9f52
2 changed files with 9 additions and 8 deletions

View File

@ -558,7 +558,7 @@ bool Tags::HandleXMLTag(const wxChar *tag, const wxChar **attrs)
wxString value = *attrs++;
if (!XMLValueChecker::IsGoodString(attr) ||
!XMLValueChecker::IsGoodString(value)) {
!XMLValueChecker::IsGoodLongString(value)) {
break;
}

View File

@ -36,19 +36,20 @@
// Length check. Is in part about not supplying malicious strings to file functions.
bool XMLValueChecker::IsGoodString(const wxString & str)
{
size_t len = str.length();
int nullIndex = str.Find('\0', false);
if ((len <= PLATFORM_MAX_PATH) && // Shouldn't be any reason for longer strings, except intentional file corruption.
(nullIndex == -1)) // No null characters except terminator.
// Originally based on MAX_PATH, which is way too limiting and just wrong since
// the length check is for a plain string and not a filename
if (IsGoodLongString(str) && str.length() <= 4096) // Shouldn't be any reason for longer strings, except intentional file corruption.
{
return true;
else
return false; // good place for a breakpoint
}
return false;
}
// No length check, as e.g. labels could be very long.
bool XMLValueChecker::IsGoodLongString(const wxString & str)
{
return str.Find('\0', false) == -1; // No null characters except terminator.
return str.Find('\0', false) == wxNOT_FOUND; // No null characters except terminator.
}