Commit 31ce789a070a57c99b42c37b2634bfb296d86442

Authored by Philippe Lagadec
1 parent 959bc8d1

olefile: fixed slight bug in OleStream

oletools/thirdparty/olefile/olefile.py
@@ -195,6 +195,7 @@ __version__ = '0.44' @@ -195,6 +195,7 @@ __version__ = '0.44'
195 # - in OleStream use _raise_defect instead of exceptions 195 # - in OleStream use _raise_defect instead of exceptions
196 # 2016-04-27 - added support for incomplete streams and incorrect 196 # 2016-04-27 - added support for incomplete streams and incorrect
197 # directory entries (to read malformed documents) 197 # directory entries (to read malformed documents)
  198 +# 2016-05-04 - fixed slight bug in OleStream
198 199
199 #----------------------------------------------------------------------------- 200 #-----------------------------------------------------------------------------
200 # TODO (for version 1.0): 201 # TODO (for version 1.0):
@@ -857,6 +858,7 @@ class OleStream(io.BytesIO): @@ -857,6 +858,7 @@ class OleStream(io.BytesIO):
857 log.debug('Read data of length %d, less than expected stream size %d' % (len(data), size)) 858 log.debug('Read data of length %d, less than expected stream size %d' % (len(data), size))
858 # TODO: provide details in exception message 859 # TODO: provide details in exception message
859 self.ole._raise_defect(DEFECT_INCORRECT, 'OLE stream size is less than declared') 860 self.ole._raise_defect(DEFECT_INCORRECT, 'OLE stream size is less than declared')
  861 + self.size = len(data)
860 # when all data is read in memory, BytesIO constructor is called 862 # when all data is read in memory, BytesIO constructor is called
861 io.BytesIO.__init__(self, data) 863 io.BytesIO.__init__(self, data)
862 # Then the OleStream object can be used as a read-only file object. 864 # Then the OleStream object can be used as a read-only file object.