nanonyme / pefile

Automatically exported from code.google.com/p/pefile
Other
0 stars 0 forks source link

crash if file size > memory size #20

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
1.
pefile crash when we use pefile.PE(filename)
because that time, the memory only 2G total, but the file size if large than 2G 
(some is large 4G)
so, the pefile is crash

2.
if you want to delete the file (os.remove(filename)), it crash again !
the file will not be deleted until the whole python script is terminated.
because the pefile crash in line 1554, and then, the file is opened, and the 
file handler is not closed, that is, the file is used now......

reason:
pefile line 1554:
self.__data__ = fd.read()

solutions
1:
it would be in try... except...

2:
check memory size which is will be used is larger than the file size

3:
file map (mmap in linux)

Original issue reported on code.google.com by newpubli...@gmail.com on 23 Oct 2010 at 7:36

GoogleCodeExporter commented 9 years ago

Original comment by ero.carr...@gmail.com on 23 Oct 2010 at 2:54

GoogleCodeExporter commented 9 years ago
I like the mmap suggestion. It seem the mmap Python module is standard and 
works across different platforms. Please try with the attached version of 
pefile.py. I think the problems you had will disappear.

Original comment by ero.carr...@gmail.com on 28 Oct 2010 at 1:45

Attachments: