From 8a2aada2b2bdd1b3f521bffdad12a6c21ac30c3a Mon Sep 17 00:00:00 2001 From: Maciej Kotowicz Date: Wed, 19 Jul 2023 15:01:01 +0200 Subject: [PATCH] fix PE.get_data Fix a situation when `length` passed to .get_data is 0 - expected results will be an empty string but currently if rva is outside any section returned data will be unbounded --- pefile.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pefile.py b/pefile.py index f2efd2b..4b5ccc8 100644 --- a/pefile.py +++ b/pefile.py @@ -6409,10 +6409,10 @@ def get_data(self, rva=0, length=None): s = self.get_section_by_rva(rva) - if length: - end = rva + length - else: + if length is None: end = None + else: + end = rva + length if not s: if rva < len(self.header):