Skip to content
This repository has been archived by the owner on Jan 7, 2025. It is now read-only.

Commit

Permalink
Merge pull request #15 from intel/csv/init_buffer
Browse files Browse the repository at this point in the history
csv: use parent init_buffer() to reinit insn buffer
  • Loading branch information
Wenzel authored Sep 11, 2024
2 parents baf3e1f + 89a8b0f commit 7a5bf2f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion vmsifter/fuzzer/csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def __init__(self, insn_buffer: Optional[bytearray] = None, extra_params: Option
self.reader = csv.DictReader(f)
self.row = next(self.reader)
insn = bytearray.fromhex(self.row["insn"])
super().__init__(insn_buffer=insn, extra_params=extra_params)
self.init_buffer(buffer=insn)

if settings.extra_byte != 0:
self.insn_length += settings.extra_byte
Expand Down
9 changes: 7 additions & 2 deletions vmsifter/fuzzer/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,14 @@ def _get_default_buffer():
cache_dyna_insn_buf_size: int = field(init=False, default=settings.insn_buf_size)

def __attrs_post_init__(self):
self.init_buffer(self.insn_buffer)

# open this method since we might need to reinit the buffer in a child class
# due to additional fuzzer params
def init_buffer(self, buffer):
min_len = settings.min_prefix_count + 1
if self.insn_buffer is None:
self.insn_length = min_len # type: ignore[unreachable]
if buffer is None:
self.insn_length = min_len
self.insn_buffer = self.__class__._get_default_buffer()
else:
self.insn_length = len(self.insn_buffer)
Expand Down

0 comments on commit 7a5bf2f

Please sign in to comment.