Fix a possible out-of-bounds access in SynchData::decode().

This also avoids an extra memory copy.
This commit is contained in:
Tsuda Kageyu
2016-02-19 20:58:09 +09:00
parent 2166d703e0
commit 8c4b484e67
2 changed files with 17 additions and 12 deletions

View File

@ -41,6 +41,7 @@ class TestID3v2SynchData : public CppUnit::TestFixture
CPPUNIT_TEST(testDecode1);
CPPUNIT_TEST(testDecode2);
CPPUNIT_TEST(testDecode3);
CPPUNIT_TEST(testDecode4);
CPPUNIT_TEST_SUITE_END();
public:
@ -113,6 +114,14 @@ public:
CPPUNIT_ASSERT_EQUAL(ByteVector("\xff\xff", 2), a);
}
void testDecode4()
{
ByteVector a("\xff\xff\xff", 3);
a = ID3v2::SynchData::decode(a);
CPPUNIT_ASSERT_EQUAL((unsigned int)3, a.size());
CPPUNIT_ASSERT_EQUAL(ByteVector("\xff\xff\xff", 3), a);
}
};
CPPUNIT_TEST_SUITE_REGISTRATION(TestID3v2SynchData);