Skip to content

Commit

Permalink
fix(UUID): UUID parser silently ignores too long strings #4375 (#4384)
Browse files Browse the repository at this point in the history
  • Loading branch information
aleks-f committed Jan 5, 2024
1 parent a9d0989 commit 67c1a8a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Foundation/src/UUID.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ bool UUID::tryParse(const std::string& uuid)
bool haveHyphens = false;
if (uuid[8] == '-' && uuid[13] == '-' && uuid[18] == '-' && uuid[23] == '-')
{
if (uuid.size() >= 36)
if (uuid.size() == 36)
haveHyphens = true;
else
return false;
Expand Down
9 changes: 9 additions & 0 deletions Foundation/testsuite/src/UUIDTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,15 @@ void UUIDTest::testParse()
catch (Poco::SyntaxException&)
{
}

try
{
uuid.parse("495cff3a-a4b3-11ee-9e54-9cb6d0f68b51AA");
fail("invalid UUID - must throw");
}
catch (Poco::SyntaxException&)
{
}
}


Expand Down

0 comments on commit 67c1a8a

Please sign in to comment.