Skip to content

Commit eec3321

Browse files
marinelaymarinelaypeace-maker
authored
Fix passing bytes to context.log_file and crc.BitPolynom (#2389)
* Fix incosistent usage of bytes/str * update changelog * Update CHANGELOG --------- Co-authored-by: marinelay <[email protected]> Co-authored-by: Peace-Maker <[email protected]>
1 parent d2a02a7 commit eec3321

File tree

3 files changed

+6
-0
lines changed

3 files changed

+6
-0
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,15 @@ The table below shows which release corresponds to each branch, and what date th
7777
- [#2327][2327] Add basic support to debug processes on Windows
7878
- [#2322][2322] Add basic RISCV64 shellcraft support
7979
- [#2330][2330] Change `context.newline` when setting `context.os` to `"windows"`
80+
- [#2389][2389] Fix passing bytes to `context.log_file` and `crc.BitPolynom`
8081

8182
[2360]: https://github.com/Gallopsled/pwntools/pull/2360
8283
[2356]: https://github.com/Gallopsled/pwntools/pull/2356
8384
[2374]: https://github.com/Gallopsled/pwntools/pull/2374
8485
[2327]: https://github.com/Gallopsled/pwntools/pull/2327
8586
[2322]: https://github.com/Gallopsled/pwntools/pull/2322
8687
[2330]: https://github.com/Gallopsled/pwntools/pull/2330
88+
[2389]: https://github.com/Gallopsled/pwntools/pull/2389
8789

8890
## 4.13.0 (`beta`)
8991

pwnlib/context/__init__.py

+2
Original file line numberDiff line numberDiff line change
@@ -1033,6 +1033,8 @@ def log_file(self, value):
10331033
"""
10341034
if isinstance(value, (bytes, six.text_type)):
10351035
# check if mode was specified as "[value],[mode]"
1036+
from pwnlib.util.packing import _need_text
1037+
value = _need_text(value)
10361038
if ',' not in value:
10371039
value += ',a'
10381040
filename, mode = value.rsplit(',', 1)

pwnlib/util/crc/__init__.py

+2
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ class BitPolynom(object):
7474

7575
def __init__(self, n):
7676
if isinstance(n, (bytes, six.text_type)):
77+
from pwnlib.util.packing import _need_text
78+
n = _need_text(n)
7779
self.n = 0
7880
x = BitPolynom(2)
7981
try:

0 commit comments

Comments
 (0)