fix(UUID): UUID parser silently ignores too long strings #4375 (#4384)

This commit is contained in:
Aleksandar Fabijanic 2024-01-05 12:59:01 +01:00
parent a9d098990e
commit 67c1a8a3bc
2 changed files with 10 additions and 1 deletions

View File

@ -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;

View File

@ -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&)
{
}
}