leosongwei / mutagen

Automatically exported from code.google.com/p/mutagen
GNU General Public License v2.0
0 stars 0 forks source link

EOFError when reading too-short MP3s #110

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
When an MP3 file is truncated but contains a full header, id3.py can raise an 
unhanded EOFError in __fullread(). With the attached test.mp3, the following 
one-liner results in the following traceback. (I ran this against svn r108 of 
mutagen.)

$ python -c 'import mutagen; print mutagen.File("test.mp3")'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "mutagen/__init__.py", line 216, in File
    if score > 0: return Kind(filename)
  File "mutagen/__init__.py", line 75, in __init__
    self.load(filename, *args, **kwargs)
  File "mutagen/id3.py", line 2070, in load
    try: self.tags = ID3(filename, **kwargs)
  File "mutagen/id3.py", line 76, in __init__
    super(ID3, self).__init__(*args, **kwargs)
  File "mutagen/_util.py", line 107, in __init__
    super(DictProxy, self).__init__(*args, **kwargs)
  File "mutagen/__init__.py", line 39, in __init__
    self.load(*args, **kwargs)
  File "mutagen/id3.py", line 137, in load
    data = self.__fullread(self.size - 10)
  File "mutagen/id3.py", line 84, in __fullread
    (long(size), long(self.__filesize), self.filename))
EOFError: Requested 0x14632 of 0x594 (../test.mp3)

Original issue reported on code.google.com by adrian.sampson on 17 May 2012 at 6:03

Attachments:

GoogleCodeExporter commented 9 years ago
I think this is on purpose. Use id3.error to handle it.

Original comment by reiter.christoph@gmail.com on 19 Jul 2012 at 11:20

GoogleCodeExporter commented 9 years ago

Original comment by reiter.christoph@gmail.com on 19 Jul 2012 at 12:03

GoogleCodeExporter commented 9 years ago
No, the EOFError raised here is the standard Python built-in EOFError, not a 
subtype of mutagen.id3.error. The following script, which catches id3.error, 
lets the same exception through.

import mutagen
try:
    print mutagen.File('test.mp3')
except mutagen.id3.error:
    print 'id3 error'

Original comment by adrian.sampson on 19 Jul 2012 at 4:00

GoogleCodeExporter commented 9 years ago
Right, sorry.

Original comment by reiter.christoph@gmail.com on 19 Jul 2012 at 6:12

GoogleCodeExporter commented 9 years ago
mutagen has moved to Bitbucket: https://bitbucket.org/lazka/mutagen/issue/110

Original comment by reiter.christoph@gmail.com on 4 Jul 2014 at 3:38