Skip to content

Commit

Permalink
Avoid infinite loop on corrupt stream recording (#96881)
Browse files Browse the repository at this point in the history
* Avoid infinite loop on corrupt stream recording

* Update tests
  • Loading branch information
uvjustin authored and frenck committed Jul 20, 2023
1 parent c118574 commit 58c3c8a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion homeassistant/components/stream/fmp4utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/components/stream/test_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ def mux(self, packet):
# 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."""
Expand Down

0 comments on commit 58c3c8a

Please sign in to comment.