Skip to content

bpo-31848: Fix broken error handling in Aifc_read.initfp() when the SSND chunk is not found #5240

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

Merged
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions Lib/aifc.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ def initfp(self, file):
else:
raise Error('not an AIFF or AIFF-C file')
self._comm_chunk_read = 0
self._ssnd_chunk = None
while 1:
self._ssnd_seek_needed = 1
try:
Expand Down
8 changes: 8 additions & 0 deletions Lib/test/test_aifc.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,14 @@ def test_read_no_comm_chunk(self):
b = io.BytesIO(b'FORM' + struct.pack('>L', 4) + b'AIFF')
self.assertRaises(aifc.Error, aifc.open, b)

def test_read_no_ssnd_chunk(self):
b = b'FORM' + struct.pack('>L', 4) + b'AIFC'
b += b'COMM' + struct.pack('>LhlhhLL', 38, 0, 0, 0, 0, 0, 0)
b += b'NONE' + struct.pack('B', 14) + b'not compressed' + b'\x00'
with self.assertRaisesRegex(aifc.Error, 'COMM chunk and/or SSND chunk'
' missing'):
aifc.open(io.BytesIO(b))

def test_read_wrong_compression_type(self):
b = b'FORM' + struct.pack('>L', 4) + b'AIFC'
b += b'COMM' + struct.pack('>LhlhhLL', 23, 0, 0, 0, 0, 0, 0)
Expand Down
1 change: 1 addition & 0 deletions Misc/ACKS
Original file line number Diff line number Diff line change
Expand Up @@ -1505,6 +1505,7 @@ Nicholas Spies
Per Spilling
Joshua Spoerri
Noah Spurrier
Zackery Spytz
Nathan Srebro
RajGopal Srinivasan
Tage Stabell-Kulo
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix the error handling in Aifc_read.initfp() when the SSND chunk is not found.
Patch by Zackery Spytz.