Repository navigation
opus_tags: validate Ogg serial, page sequence, and OpusTags flags (OGG-RETAG-STREAM-CHECK) - #386
Open
tahffo68hk-hash wants to merge 1 commit into
Open
tahffo68hk-hash wants to merge 1 commit into
tahffo68hk-hash wants to merge 1 commit into
Conversation
… and OpusTags flags (OGG-RETAG-STREAM-CHECK)
demoz53
added a commit
to demoz53/leonida
that referenced
this pull request
Nov 24, 2026
…uence, and OpusTags flags (OGG-RETAG-STREAM-CHECK)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Claimed in the coordination issue as:
OGG-RETAG-STREAM-CHECKProblem
tools/opus_tags.pyvalidates Ogg page CRCs inretag()before rewriting page 1, but did not check:OpusTags), and all subsequent audio pages.0, page 1 =1, audio pages =2, 3, ...).OpusTagspage (such as the continuation flag0x01, or unexpected BOS/EOS flags0x02/0x04thatretag()would silently overwrite with0x00).Structurally malformed Ogg Opus inputs with valid page CRCs were therefore accepted and rewritten.
Fix
retag(), verify page 0 has sequence number0, every page shares the same logical bitstream serial number, subsequent audio pages have contiguous sequence numbers starting at2, and page 1 does not carry the continuation (0x01) or BOS/EOS (0x02/0x04) flags.tests/test_opus_tags.py(TestRetag.test_retag_rejects_serial_mismatch_sequence_gap_and_continuation_flags).Verification
python -I tests/test_opus_tags.py -v TestRetag TestPacket-> 7/7 OKpython -I tests/test_opus_tags_dialogue_conflicts.py-> 6/6 OKtest_cli_reports_incomplete_directory_discoveryintest_opus_tags.pyhas a pre-existing Windows path-repr failure tracked in tests: expect the unreadable path as OSError prints it (bink_names, opus_tags, world_names) #312 and was left untouched.)中文翻译
在协调帖 #14 中认领的 ID:
OGG-RETAG-STREAM-CHECK问题描述
tools/opus_tags.py中的retag()在改写第 1 页前校验了各页的 Ogg CRC,但遗漏了以下结构校验:OpusTags)及后续所有音频页的逻辑比特流序列号(serial)一致性。0、第 1 页为1、后续音频页为2, 3, ...)。OpusTags页的页头标志位(如续页标记0x01,或会被retag()静默覆写为0x00的 BOS/EOS 标志0x02/0x04)。因此 CRC 正确但结构异常的 Ogg Opus 文件会被接受并改写。
修复方案
retag()中校验第 0 页序号为0、所有页面逻辑流序列号一致、后续音频页序号从2开始连续递增,且第 1 页不带续页标记(0x01)或 BOS/EOS 标志(0x02/0x04)。tests/test_opus_tags.py中补充合成回归测试(覆盖 6 类结构异常)。验证结果
tests/test_opus_tags.py -v TestRetag TestPacket:7/7 通过。tests/test_opus_tags_dialogue_conflicts.py:6/6 通过。test_opus_tags.py中test_cli_reports_incomplete_directory_discovery在 Windows 上存在 tests: expect the unreadable path as OSError prints it (bink_names, opus_tags, world_names) #312 已跟踪的既有路径转义失败,未改动。)