From eec3321ae9c1306b64231f6538a573e7265bdb11 Mon Sep 17 00:00:00 2001 From: marinelay Date: Mon, 22 Apr 2024 05:18:28 +0900 Subject: [PATCH] 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 Co-authored-by: Peace-Maker --- CHANGELOG.md | 2 ++ pwnlib/context/__init__.py | 2 ++ pwnlib/util/crc/__init__.py | 2 ++ 3 files changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2fb9e31d1..631184f05 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -77,6 +77,7 @@ 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 @@ -84,6 +85,7 @@ The table below shows which release corresponds to each branch, and what date th [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`) diff --git a/pwnlib/context/__init__.py b/pwnlib/context/__init__.py index 3d090e138..3bf265893 100644 --- a/pwnlib/context/__init__.py +++ b/pwnlib/context/__init__.py @@ -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) diff --git a/pwnlib/util/crc/__init__.py b/pwnlib/util/crc/__init__.py index f4271b23f..80a5c5649 100644 --- a/pwnlib/util/crc/__init__.py +++ b/pwnlib/util/crc/__init__.py @@ -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: