Skip to content

ogg vorbis corruption #775

@thepaka

Description

@thepaka

Hello,
I'm trying to debug an ogg vorbis corruption that happens when editing tags with taglib. And I just found something suspicious in Ogg::File::writePacket .

Seems that if lastPage has 2 packets, the beginning of the second will be lost because the if condition is true only if lastPage has 3 packets or more.

diff --git a/taglib/ogg/oggfile.cpp b/taglib/ogg/oggfile.cpp
index 86b0b07..c36e4d4 100644
--- a/taglib/ogg/oggfile.cpp
+++ b/taglib/ogg/oggfile.cpp
@@ -253,7 +253,7 @@ void Ogg::File::writePacket(unsigned int i, const ByteVector &packet)
   ByteVectorList packets = firstPage->packets();
   packets[i - firstPage->firstPacketIndex()] = packet;
 
-  if(firstPage != lastPage && lastPage->packetCount() > 2) {
+  if(firstPage != lastPage && lastPage->packetCount() > 1) {
     ByteVectorList lastPagePackets = lastPage->packets();
     lastPagePackets.erase(lastPagePackets.begin());
     packets.append(lastPagePackets);

This change fixed the corruption issue in my test case (using vorbiscomment and tagwriter). I will do more tests in the next days.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions