mirror of
https://github.com/monero-project/monero.git
synced 2026-06-12 11:01:34 -07:00
Merge pull request #10696
d42de75tests: cover truncated \u escape at end of buffer in match_string2 (alhudz)524b0d0fix off-by-one over-read in match_string2 unicode escape parsing (alhudz)
This commit is contained in:
@@ -129,7 +129,7 @@ namespace misc_utils
|
|||||||
case '/': //Slash character
|
case '/': //Slash character
|
||||||
val.push_back('/');break;
|
val.push_back('/');break;
|
||||||
case 'u': //Unicode code point
|
case 'u': //Unicode code point
|
||||||
if (buf_end - it < 4)
|
if (buf_end - it < 5)
|
||||||
{
|
{
|
||||||
ASSERT_MES_AND_THROW("Invalid Unicode escape sequence");
|
ASSERT_MES_AND_THROW("Invalid Unicode escape sequence");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1856,6 +1856,16 @@ TEST(parsing, unicode)
|
|||||||
si = s.begin();
|
si = s.begin();
|
||||||
EXPECT_THROW(epee::misc_utils::parse::match_string2(si, s.end(), bs), std::runtime_error);
|
EXPECT_THROW(epee::misc_utils::parse::match_string2(si, s.end(), bs), std::runtime_error);
|
||||||
|
|
||||||
|
// truncated \u escape with buf_end right after the hex digits must throw,
|
||||||
|
// not read past buf_end (the closing quote is absent here on purpose)
|
||||||
|
s = "\"\\u123";
|
||||||
|
si = s.begin();
|
||||||
|
EXPECT_THROW(epee::misc_utils::parse::match_string2(si, s.end(), bs), std::runtime_error);
|
||||||
|
|
||||||
|
s = "\"\\u";
|
||||||
|
si = s.begin();
|
||||||
|
EXPECT_THROW(epee::misc_utils::parse::match_string2(si, s.end(), bs), std::runtime_error);
|
||||||
|
|
||||||
s = "\"\\u1234\"";
|
s = "\"\\u1234\"";
|
||||||
si = s.begin();
|
si = s.begin();
|
||||||
epee::misc_utils::parse::match_string2(si, s.end(), bs);
|
epee::misc_utils::parse::match_string2(si, s.end(), bs);
|
||||||
|
|||||||
Reference in New Issue
Block a user