Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

instantiating OleID with data fails #695

Closed
jloehel opened this issue Jun 14, 2021 · 1 comment · Fixed by #696
Closed

instantiating OleID with data fails #695

jloehel opened this issue Jun 14, 2021 · 1 comment · Fixed by #696
Assignees
Milestone

Comments

@jloehel
Copy link
Contributor

jloehel commented Jun 14, 2021

Error:

...
     oid = oletools.oleid.OleID(filename=self.filename, data=self.filedata)
  File "/opt/hostedtoolcache/Python/3.6.13/x64/lib/python3.6/site-packages/oletools/oleid.py", line 238, in __init__
    self.data_bytesio = io.BytesIO(self.data)
AttributeError: 'OleID' object has no attribute 'data'

Code:

oletools/oletools/oleid.py

Lines 234 to 238 in 75c0696

if data is None:
self.file_on_disk = True # useful for some check that don't work in memory
with open(filename, 'rb') as f:
self.data = f.read()
self.data_bytesio = io.BytesIO(self.data)

Fix:

if data is None: 
     self.file_on_disk = True  # useful for some check that don't work in memory 
     with open(filename, 'rb') as f: 
         self.data = f.read()
else:
     self.data = data
 self.data_bytesio = io.BytesIO(self.data)  
jloehel added a commit to jloehel/oletools that referenced this issue Jun 14, 2021
It's necessary to set self.data if data is not None.

Fixes: decalage2#695

Signed-off-by: Jürgen Löhel <juergen.loehel@inlyse.com>
@decalage2 decalage2 self-assigned this Jun 15, 2021
@decalage2 decalage2 added this to the oletools 0.60 milestone Jun 15, 2021
@decalage2
Copy link
Owner

Good catch, thanks!

c-rosenberg pushed a commit to HeinleinSupport/oletools that referenced this issue Jun 22, 2021
It's necessary to set self.data if data is not None.

Fixes: decalage2#695

Signed-off-by: Jürgen Löhel <juergen.loehel@inlyse.com>
c-rosenberg pushed a commit to HeinleinSupport/oletools that referenced this issue Dec 2, 2021
It's necessary to set self.data if data is not None.

Fixes: decalage2#695

Signed-off-by: Jürgen Löhel <juergen.loehel@inlyse.com>
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants