mirror of
https://github.com/taglib/taglib.git
synced 2025-07-18 21:14:23 -04:00
Fix parsing of regular 32-bit integers in SynchData::toUInt()
BUG:231075 git-svn-id: svn://anonsvn.kde.org/home/kde/trunk/kdesupport/taglib@1115275 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
This commit is contained in:
BIN
tests/data/compressed_id3_frame.mp3
Normal file
BIN
tests/data/compressed_id3_frame.mp3
Normal file
Binary file not shown.
@ -61,6 +61,7 @@ class TestID3v2 : public CppUnit::TestFixture
|
||||
CPPUNIT_TEST(testUpdateGenre24);
|
||||
CPPUNIT_TEST(testUpdateDate22);
|
||||
// CPPUNIT_TEST(testUpdateFullDate22); TODO TYE+TDA should be upgraded to TDRC together
|
||||
CPPUNIT_TEST(testCompressedFrameWithBrokenLength);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
public:
|
||||
@ -455,6 +456,19 @@ public:
|
||||
CPPUNIT_ASSERT_EQUAL(String("2010-04-03"), f.ID3v2Tag()->frameListMap()["TDRC"].front()->toString());
|
||||
}
|
||||
|
||||
void testCompressedFrameWithBrokenLength()
|
||||
{
|
||||
MPEG::File f("data/compressed_id3_frame.mp3", false);
|
||||
CPPUNIT_ASSERT(f.ID3v2Tag()->frameListMap().contains("APIC"));
|
||||
ID3v2::AttachedPictureFrame *frame =
|
||||
static_cast<TagLib::ID3v2::AttachedPictureFrame*>(f.ID3v2Tag()->frameListMap()["APIC"].front());
|
||||
CPPUNIT_ASSERT(frame);
|
||||
CPPUNIT_ASSERT_EQUAL(String("image/bmp"), frame->mimeType());
|
||||
CPPUNIT_ASSERT_EQUAL(ID3v2::AttachedPictureFrame::Other, frame->type());
|
||||
CPPUNIT_ASSERT_EQUAL(String(""), frame->description());
|
||||
CPPUNIT_ASSERT_EQUAL(TagLib::uint(86414), frame->picture().size());
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION(TestID3v2);
|
||||
|
@ -34,6 +34,8 @@ class TestID3v2SynchData : public CppUnit::TestFixture
|
||||
CPPUNIT_TEST(test1);
|
||||
CPPUNIT_TEST(test2);
|
||||
CPPUNIT_TEST(test3);
|
||||
CPPUNIT_TEST(testToUIntBroken);
|
||||
CPPUNIT_TEST(testToUIntBrokenAndTooLarge);
|
||||
CPPUNIT_TEST(testDecode1);
|
||||
CPPUNIT_TEST(testDecode2);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
@ -67,6 +69,23 @@ public:
|
||||
CPPUNIT_ASSERT_EQUAL(ID3v2::SynchData::fromUInt(129), v);
|
||||
}
|
||||
|
||||
void testToUIntBroken()
|
||||
{
|
||||
char data[] = { 0, 0, 0, -1 };
|
||||
char data2[] = { 0, 0, -1, -1 };
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(TagLib::uint(255), ID3v2::SynchData::toUInt(ByteVector(data, 4)));
|
||||
CPPUNIT_ASSERT_EQUAL(TagLib::uint(65535), ID3v2::SynchData::toUInt(ByteVector(data2, 4)));
|
||||
}
|
||||
|
||||
void testToUIntBrokenAndTooLarge()
|
||||
{
|
||||
char data[] = { 0, 0, 0, -1, 0 };
|
||||
ByteVector v(data, 5);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(TagLib::uint(255), ID3v2::SynchData::toUInt(v));
|
||||
}
|
||||
|
||||
void testDecode1()
|
||||
{
|
||||
ByteVector a("\xff\x00\x00", 3);
|
||||
|
Reference in New Issue
Block a user