Ishan112 / pefile

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

Defect in 1.2.10-102: mmap.mmap() on empty file raises exception #25

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hi,

I'm with VMware and we are using this module to serve our symbols server. We 
have upgraded to 1.2.10-102 recently, and I noticed you have switched to use 
mmap module to load a file to self.__data__ (you were just reading the file 
.read() in earlier versions). However, line 1731 chokes when the file is empty. 
i.e. when passing 0 to the second parameter to mmap.mmap(), it expects the file 
to be non-zero!!

Traceback (most recent call last):
  File "/build/apps/symindex/lib/repository.py", line 106, in run
    pe = pefile.PE(path)
  File "build/bdist.linux-i686/egg/pefile.py", line 1696, in __init__
    self.__parse__(name, data, fast_load)
  File "build/bdist.linux-i686/egg/pefile.py", line 1731, in __parse__
    self.__data__ = mmap.mmap( self.fileno, 0, access = mmap.ACCESS_READ  )
error: [Errno 22] Invalid argument

please fix it.

Original issue reported on code.google.com by eyuw...@gmail.com on 16 Apr 2011 at 1:21

GoogleCodeExporter commented 9 years ago

Original comment by ero.carr...@gmail.com on 20 Apr 2011 at 7:34

GoogleCodeExporter commented 9 years ago

Original comment by ero.carr...@gmail.com on 20 Apr 2011 at 4:48

GoogleCodeExporter commented 9 years ago
Fixed in revision 105. A check is now made for zero-length files

Original comment by ero.carr...@gmail.com on 20 Apr 2011 at 5:28

GoogleCodeExporter commented 9 years ago
Thanks!

Original comment by eyuw...@gmail.com on 21 Apr 2011 at 7:18