-Fixed parsing problem on files specifying a FileAligment of zero
-Fixed problem parsing the Bound Imports directory when it contained invalid data. In some instances pefile would get caught up trying to make sense of arbitrary data. Now when empty strings are found as module names in the Bound Import structures, the parsing is aborted



git-svn-id: http://pefile.googlecode.com/svn/trunk@48 8842bc4e-7134-0410-8230-5dc5194fb5c1
diff --git a/pefile.py b/pefile.py
index 55b22de..e22fd1a 100644
--- a/pefile.py
+++ b/pefile.py
@@ -21,7 +21,7 @@
 """
 
 __author__ = 'Ero Carrera'
-__version__ = '1.2.9'
+__version__ = '1.2.9.1'
 __contact__ = 'ero@dkbza.org'
 
 
@@ -1744,11 +1744,11 @@
             # PointerToRawData. The following code will do the same.
             #
             
-            alignment = self.OPTIONAL_HEADER.FileAlignment
+            #alignment = self.OPTIONAL_HEADER.FileAlignment
             section_data_start = section.PointerToRawData
-            #section_data_start = int(section_data_start/alignment)*alignment
             
-            if section.PointerToRawData % self.OPTIONAL_HEADER.FileAlignment != 0:
+            if ( self.OPTIONAL_HEADER.FileAlignment != 0 and 
+                (section.PointerToRawData % self.OPTIONAL_HEADER.FileAlignment) != 0):
                 self.__warnings.append(
                     ('Error parsing section %d. ' % i) +
                     'Suspicious value for FileAlignment in the Optional Header. ' +
@@ -1877,16 +1877,24 @@
                         "IMAGE_BOUND_FORWARDER_REF cannot be read")
                 rva += bnd_frwd_ref.sizeof()
                 
+                name_str =  self.get_string_from_data(
+                    start+bnd_frwd_ref.OffsetModuleName, self.__data__)
+                    
+                if not name_str:
+                    break
                 forwarder_refs.append(BoundImportRefData(
                     struct = bnd_frwd_ref,
-                    name =  self.get_string_from_data(
-                        start+bnd_frwd_ref.OffsetModuleName, self.__data__)))
+                    name = name_str))
                 
+            name_str = self.get_string_from_data(
+                start+bnd_descr.OffsetModuleName, self.__data__)
+                
+            if not name_str:
+                break
             bound_imports.append(
                 BoundImportDescData(
                     struct = bnd_descr,
-                    name = self.get_string_from_data(
-                        start+bnd_descr.OffsetModuleName, self.__data__),
+                    name = name_str,
                     entries = forwarder_refs))
                     
         return bound_imports