fix(drm): raise ValueError when a file ends inside a box largesize in read_top_boxes

This commit is contained in:
imSp4rky
2026-11-29 12:27:24 -07:00
parent 90dfe1c7bd
commit b429f612fb
2 changed files with 14 additions and 3 deletions
+8 -1
View File
@@ -4,7 +4,7 @@ from uuid import UUID
import pytest
from unshackle.core.drm.verify import PIFF_TENC, PIFF_TFXD, KidMap, kid_windows, pick_windows
from unshackle.core.drm.verify import PIFF_TENC, PIFF_TFXD, KidMap, kid_windows, pick_windows, read_top_boxes
A, B, C = UUID(int=0xA), UUID(int=0xB), UUID(int=0xC)
@@ -192,6 +192,13 @@ def test_oversized_box(tmp_path: Path) -> None:
assert kid_windows(path) is None
def test_box_cut_inside_its_largesize(tmp_path: Path) -> None:
path = tmp_path / "cut.mp4"
path.write_bytes(struct.pack(">I4s", 1, b"moof") + bytes(4))
with path.open("rb") as f, pytest.raises(ValueError):
list(read_top_boxes(f))
def test_not_a_fragmented_mp4(tmp_path: Path) -> None:
path = tmp_path / "video.ts"
path.write_bytes(b"\x47" * 188 * 4)