Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix Input out of bounds of slice #132

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions go-ogg/ogg-demuxer.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,16 +157,18 @@ func (demuxer *Demuxer) Input(buf []byte) (err error) {
} else if stream.lost == 0 && page.isContinuePacket {
appendLen := 0
for ; idx < int(page.segmentsCount); idx++ {
appendLen += int(page.seqmentTable[idx])
if page.seqmentTable[idx] < 255 {
stream.cache = append(stream.cache, tmp[:appendLen]...)
if demuxer.OnPacket != nil {
demuxer.OnPacket(stream.streamId, stream.currentPage.granulePos, stream.cache, 0)
}
page.packets = append(page.packets, stream.cache)
stream.cache = stream.cache[:0]
tmp = tmp[appendLen:]
}
//fix out of bound of tmp
curSegLen := int(page.seqmentTable[idx])
appendLen += curSegLen
if page.seqmentTable[idx] < 255 {
stream.cache = append(stream.cache, tmp[:curSegLen]...)
if demuxer.OnPacket != nil {
demuxer.OnPacket(stream.streamId, stream.currentPage.granulePos, stream.cache, 0)
}
page.packets = append(page.packets, stream.cache)
stream.cache = stream.cache[:0]
tmp = tmp[curSegLen:]
}
}
}

Expand Down