From 15a538f9e75b0b97443ef2e139e470db03d5da89 Mon Sep 17 00:00:00 2001 From: j-t-1 <120829237+j-t-1@users.noreply.github.com> Date: Sun, 9 Jun 2024 10:10:52 +0100 Subject: [PATCH] Remove "OC Patch" comments This information is available from git blame --- pefile.py | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/pefile.py b/pefile.py index d28ada2..890a42d 100644 --- a/pefile.py +++ b/pefile.py @@ -1004,7 +1004,6 @@ def __unpack__(self, data): if len(data) > self.__format_length__: data = data[: self.__format_length__] - # OC Patch: # Some malware have incorrect header lengths. # Fail gracefully if this occurs # Buggy malware: a29b0118af8b7408444df81701ad5a7f @@ -3078,7 +3077,6 @@ def __parse__(self, fname, data, fast_load): if not self.DOS_HEADER or self.DOS_HEADER.e_magic != IMAGE_DOS_SIGNATURE: raise PEFormatError("DOS Header magic not found.") - # OC Patch: # Check for sane value in e_lfanew # if self.DOS_HEADER.e_lfanew > len(self.__data__): @@ -3094,7 +3092,6 @@ def __parse__(self, fname, data, fast_load): # We better check the signature right here, before the file screws # around with sections: - # OC Patch: # Some malware will cause the Signature value to not exist at all if not self.NT_HEADERS or not self.NT_HEADERS.Signature: raise PEFormatError("NT Headers not found.") @@ -3216,7 +3213,6 @@ def __parse__(self, fname, data, fast_load): if not self.FILE_HEADER: raise PEFormatError("File Header missing") - # OC Patch: # Die gracefully if there is no OPTIONAL_HEADER field # 975440f5ad5e2e4a92c4d9a5f22f75c1 if self.OPTIONAL_HEADER is None: @@ -3312,7 +3308,6 @@ def __parse__(self, fname, data, fast_load): offset = self.parse_sections(sections_offset) - # OC Patch: # There could be a problem if there are no raw data sections # greater than 0 # fc91013eb72529da005110a3403541b6 example @@ -3727,8 +3722,6 @@ def parse_data_directories( directories = [directories] for entry in directory_parsing: - # OC Patch: - # try: directory_index = DIRECTORY_ENTRY[entry[0]] dir_entry = self.OPTIONAL_HEADER.DATA_DIRECTORY[directory_index] @@ -3936,7 +3929,7 @@ def parse_directory_bound_imports(self, rva, size): self.__data__[rva : rva + bnd_descr_size], file_offset=rva, ) - # OC Patch: + if not bnd_frwd_ref: raise PEFormatError("IMAGE_BOUND_FORWARDER_REF cannot be read") rva += bnd_frwd_ref.sizeof() @@ -4265,7 +4258,6 @@ def parse_image_base_relocation_list(self, rva, size, fmt=None): relocations = [] while rva < end: - # OC Patch: # Malware that has bad RVA entries will cause an error. # Just continue on after an exception # @@ -4594,7 +4586,6 @@ def parse_resources_directory(self, rva, size=0, base_rva=None, level=0, dirs=No are available as its attributes. """ - # OC Patch: if dirs is None: dirs = [rva] @@ -4741,8 +4732,6 @@ def parse_resources_directory(self, rva, size=0, base_rva=None, level=0, dirs=No ) if res.DataIsDirectory: - # OC Patch: - # # One trick malware can do is to recursively reference # the next directory. This causes hilarity to ensue when # trying to parse everything correctly. @@ -5971,7 +5960,6 @@ def parse_imports( # bound. iat = self.get_import_table(first_thunk, max_length, contains_addresses) - # OC Patch: # Would crash if IAT or ILT had None type if (not iat or len(iat) == 0) and (not ilt or len(ilt) == 0): self.__warnings.append( @@ -7228,7 +7216,6 @@ def dump_dict(self): return dump_dict - # OC Patch def get_physical_by_rva(self, rva): """Gets the physical address in the PE file from an RVA value.""" try: