mirror of
https://github.com/mandiant/capa.git
synced 2026-06-12 11:01:31 -07:00
incorrect bytes() constructor usage in buf_filled_with (#3077)
This commit is contained in:
@@ -113,6 +113,7 @@
|
||||
- fix: replace assert with isinstance guard in get_callee for invalid MethodSpec tokens @williballenthin
|
||||
- fix: assign ConfigDict to model_config in ConciseModel so extra="ignore" is actually applied @williballenthin (SURF-42)
|
||||
- fix: replace assert with isinstance guard in get_callee for invalid MethodSpec tokens @williballenthin (SURF-41)
|
||||
- fix: incorrect bytes() constructor usage in buf_filled_with @mike-hunhoff #3077
|
||||
- fix: remove redundant code related to cli loading @mike-hunhoff #3076
|
||||
|
||||
### capa Explorer Web
|
||||
|
||||
@@ -57,7 +57,7 @@ def buf_filled_with(buf: bytes, character: int) -> bool:
|
||||
return all(b == character for b in buf)
|
||||
|
||||
# single big allocation, re-used each loop
|
||||
dupe_chunk = bytes(character) * SLICE_SIZE
|
||||
dupe_chunk = bytes([character]) * SLICE_SIZE
|
||||
|
||||
for offset in range(0, len(buf), SLICE_SIZE):
|
||||
# bytes objects are immutable, so the slices share the underlying array,
|
||||
|
||||
@@ -34,6 +34,12 @@ def test_buf_filled_with():
|
||||
assert buf_filled_with(b"", 0x00) is False # Empty buffer
|
||||
assert buf_filled_with(b"\x00", 0x00) is True # Single byte
|
||||
|
||||
# Large buffers (exercise chunked processing)
|
||||
assert buf_filled_with(b"A" * 5000, ord("A")) is True
|
||||
assert buf_filled_with(b"A" * 5000 + b"B", ord("A")) is False
|
||||
assert buf_filled_with(b"\xff" * 5000, 0xFF) is True
|
||||
assert buf_filled_with(b"\x00" * 5000, 0x00) is True
|
||||
|
||||
|
||||
def test_extract_ascii_strings():
|
||||
# test empty buffer
|
||||
|
||||
Reference in New Issue
Block a user