Skip to content

Commit 2699ff9

Browse files
committed
fix to_bytes_with_default
1 parent f976813 commit 2699ff9

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/padding_oracle/utils.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,10 @@ def to_bytes(data: str | bytes | list[int]) -> bytes:
4040

4141

4242
def to_bytes_with_default(maybe_bytes: list[int | None], default: bytes = b' ') -> bytes:
43-
return [default if b is None else b for b in maybe_bytes]
43+
return bytes([
44+
ord(default) if (b is None or b not in range(256)) else b
45+
for b in maybe_bytes
46+
])
4447

4548

4649
def to_bytes_ensure_complete(maybe_bytes: list[int | None]) -> bytes:

0 commit comments

Comments
 (0)