Crashes with bson error when oops is corrupted (zero bytes size)

Bug #894682 reported by Roman Yepishev
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Python OOPS Date-dir repository
Fix Released
Critical
Roman Yepishev

Bug Description

At the moment if oops is 0 bytes long (either .oops or decompressed from .bz) the reader fails with:

Tests running...
======================================================================
ERROR: oops_datedir_repo.tests.test_serializer.TestParsing.test_ioerror_on_empty_oops
----------------------------------------------------------------------
Traceback (most recent call last):
  File "oops_datedir_repo/tests/test_serializer.py", line 73, in test_ioerror_on_empty_oops
    self.assertRaises(IOError, read, source_file)
  File "/home/rtg/Projects/python-oops-datedir-repo/eggs/testtools-0.9.12-py2.6.egg/testtools/testcase.py", line 388, in assertRaises
    self.assertThat(lambda: callableObj(*args, **kwargs), matcher)
  File "/home/rtg/Projects/python-oops-datedir-repo/eggs/testtools-0.9.12-py2.6.egg/testtools/testcase.py", line 400, in assertThat
    mismatch = matcher.match(matchee)
  File "/home/rtg/Projects/python-oops-datedir-repo/eggs/testtools-0.9.12-py2.6.egg/testtools/matchers.py", line 745, in match
    mismatch = self.exception_matcher.match(exc_info)
  File "/home/rtg/Projects/python-oops-datedir-repo/eggs/testtools-0.9.12-py2.6.egg/testtools/matchers.py", line 495, in match
    mismatch = matcher.match(matchee)
  File "/home/rtg/Projects/python-oops-datedir-repo/eggs/testtools-0.9.12-py2.6.egg/testtools/testcase.py", line 380, in match
    reraise(*matchee)
  File "/home/rtg/Projects/python-oops-datedir-repo/eggs/testtools-0.9.12-py2.6.egg/testtools/matchers.py", line 738, in match
    result = matchee()
  File "/home/rtg/Projects/python-oops-datedir-repo/eggs/testtools-0.9.12-py2.6.egg/testtools/testcase.py", line 388, in <lambda>
    self.assertThat(lambda: callableObj(*args, **kwargs), matcher)
  File "oops_datedir_repo/serializer.py", line 52, in read
    return serializer_bson.read(StringIO(content))
  File "oops_datedir_repo/serializer_bson.py", line 64, in read
    report = bson.loads(fp.read())
  File "/home/rtg/Projects/python-oops-datedir-repo/eggs/bson-0.3.2-py2.6.egg/bson/__init__.py", line 75, in loads
    return decode_document(data, 0)[1]
  File "/home/rtg/Projects/python-oops-datedir-repo/eggs/bson-0.3.2-py2.6.egg/bson/codec.py", line 235, in decode_document
    length = struct.unpack("<i", data[base:base + 4])[0]
error: unpack requires a string argument of length 4

Related branches

Changed in python-oops-datedir-repo:
status: New → Triaged
importance: Undecided → Critical
Changed in python-oops-datedir-repo:
assignee: nobody → Roman Yepishev (rye)
status: Triaged → Fix Committed
Changed in python-oops-datedir-repo:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.