Commit 9225bf167cfbc821eb27624e37e6d3fb80ef7a81

Authored by decalage2
1 parent 4b28ee1b

olevba: fixed small bugs in VBA parsing code

Showing 1 changed file with 7 additions and 4 deletions
oletools/olevba.py
@@ -175,8 +175,9 @@ https://github.com/unixfreak0037/officeparser @@ -175,8 +175,9 @@ https://github.com/unixfreak0037/officeparser
175 # 2016-05-12 CH: - added support for PowerPoint 97-2003 files 175 # 2016-05-12 CH: - added support for PowerPoint 97-2003 files
176 # 2016-06-06 CH: - improved handling of unicode VBA module names 176 # 2016-06-06 CH: - improved handling of unicode VBA module names
177 # 2016-06-07 CH: - added option --relaxed, stricter parsing by default 177 # 2016-06-07 CH: - added option --relaxed, stricter parsing by default
  178 +# 2016-06-12 v0.48 PL: - fixed small bugs in VBA parsing code
178 179
179 -__version__ = '0.47' 180 +__version__ = '0.48'
180 181
181 #------------------------------------------------------------------------------ 182 #------------------------------------------------------------------------------
182 # TODO: 183 # TODO:
@@ -1469,6 +1470,8 @@ def _extract_vba(ole, vba_root, project_path, dir_path, relaxed=False): @@ -1469,6 +1470,8 @@ def _extract_vba(ole, vba_root, project_path, dir_path, relaxed=False):
1469 check_value('MODULENAME_Id', 0x0019, modulename_id) 1470 check_value('MODULENAME_Id', 0x0019, modulename_id)
1470 modulename_sizeof_modulename = struct.unpack("<L", dir_stream.read(4))[0] 1471 modulename_sizeof_modulename = struct.unpack("<L", dir_stream.read(4))[0]
1471 modulename_modulename = dir_stream.read(modulename_sizeof_modulename) 1472 modulename_modulename = dir_stream.read(modulename_sizeof_modulename)
  1473 + # TODO: preset variables to avoid "referenced before assignment" errors
  1474 + modulename_unicode_modulename_unicode = ''
1472 # account for optional sections 1475 # account for optional sections
1473 section_id = struct.unpack("<H", dir_stream.read(2))[0] 1476 section_id = struct.unpack("<H", dir_stream.read(2))[0]
1474 if section_id == 0x0047: 1477 if section_id == 0x0047:
@@ -3289,14 +3292,14 @@ def main(): @@ -3289,14 +3292,14 @@ def main():
3289 else RETURN_SEVERAL_ERRS 3292 else RETURN_SEVERAL_ERRS
3290 except ProcessingError as exc: 3293 except ProcessingError as exc:
3291 if options.output_mode in ('triage', 'unspecified'): 3294 if options.output_mode in ('triage', 'unspecified'):
3292 - print '%-12s %s - %s' % ('!ERROR', filename, exc.orig_exception) 3295 + print '%-12s %s - %s' % ('!ERROR', filename, exc.orig_exc)
3293 elif options.output_mode == 'json': 3296 elif options.output_mode == 'json':
3294 print_json(file=filename, type='error', 3297 print_json(file=filename, type='error',
3295 error=type(exc).__name__, 3298 error=type(exc).__name__,
3296 - message=str(exc.orig_exception)) 3299 + message=str(exc.orig_exc))
3297 else: 3300 else:
3298 log.exception('Error processing file %s (%s)!' 3301 log.exception('Error processing file %s (%s)!'
3299 - % (filename, exc.orig_exception)) 3302 + % (filename, exc.orig_exc))
3300 return_code = RETURN_PARSE_ERROR if return_code == 0 \ 3303 return_code = RETURN_PARSE_ERROR if return_code == 0 \
3301 else RETURN_SEVERAL_ERRS 3304 else RETURN_SEVERAL_ERRS
3302 finally: 3305 finally: