Avoid infinite loop on corrupt stream recording (#96881)

* Avoid infinite loop on corrupt stream recording

* Update tests
pull/96890/head
uvjustin 2023-07-19 15:06:04 +08:00 committed by GitHub
parent f2bd122fde
commit 3e58e1987c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View File

@ -151,7 +151,7 @@ def find_moov(mp4_io: BufferedIOBase) -> int:
while 1:
mp4_io.seek(index)
box_header = mp4_io.read(8)
if len(box_header) != 8:
if len(box_header) != 8 or box_header[0:4] == b"\x00\x00\x00\x00":
raise HomeAssistantError("moov atom not found")
if box_header[4:8] == b"moov":
return index

View File

@ -245,7 +245,7 @@ class FakePyAvBuffer:
# Forward to appropriate FakeStream
packet.stream.mux(packet)
# Make new init/part data available to the worker
self.memory_file.write(b"\x00\x00\x00\x00moov")
self.memory_file.write(b"\x00\x00\x00\x08moov")
def close(self):
"""Close the buffer."""