Skip to content

Commit

Permalink
Fix passing bytes to context.log_file and crc.BitPolynom (#2389)
Browse files Browse the repository at this point in the history
* Fix incosistent usage of bytes/str

* update changelog

* Update CHANGELOG

---------

Co-authored-by: marinelay <[email protected]>
Co-authored-by: Peace-Maker <[email protected]>
  • Loading branch information
3 people authored Apr 21, 2024
1 parent d2a02a7 commit eec3321
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,15 @@ The table below shows which release corresponds to each branch, and what date th
- [#2327][2327] Add basic support to debug processes on Windows
- [#2322][2322] Add basic RISCV64 shellcraft support
- [#2330][2330] Change `context.newline` when setting `context.os` to `"windows"`
- [#2389][2389] Fix passing bytes to `context.log_file` and `crc.BitPolynom`

[2360]: https://github.com/Gallopsled/pwntools/pull/2360
[2356]: https://github.com/Gallopsled/pwntools/pull/2356
[2374]: https://github.com/Gallopsled/pwntools/pull/2374
[2327]: https://github.com/Gallopsled/pwntools/pull/2327
[2322]: https://github.com/Gallopsled/pwntools/pull/2322
[2330]: https://github.com/Gallopsled/pwntools/pull/2330
[2389]: https://github.com/Gallopsled/pwntools/pull/2389

## 4.13.0 (`beta`)

Expand Down
2 changes: 2 additions & 0 deletions pwnlib/context/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1033,6 +1033,8 @@ def log_file(self, value):
"""
if isinstance(value, (bytes, six.text_type)):
# check if mode was specified as "[value],[mode]"
from pwnlib.util.packing import _need_text
value = _need_text(value)
if ',' not in value:
value += ',a'
filename, mode = value.rsplit(',', 1)
Expand Down
2 changes: 2 additions & 0 deletions pwnlib/util/crc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ class BitPolynom(object):

def __init__(self, n):
if isinstance(n, (bytes, six.text_type)):
from pwnlib.util.packing import _need_text
n = _need_text(n)
self.n = 0
x = BitPolynom(2)
try:
Expand Down

0 comments on commit eec3321

Please sign in to comment.