Skip to content

Commit 2d998a4

Browse files
committed
Merge branch 'stable' into beta
2 parents fa2d477 + d762fe0 commit 2d998a4

File tree

4 files changed

+14
-7
lines changed

4 files changed

+14
-7
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,11 @@ The table below shows which release corresponds to each branch, and what date th
8888

8989
- [#2214][2214] Fix bug at ssh.py:`download` and `download_file` with relative paths
9090
- [#2241][2241] Fix ssh.process not setting ssh_process.cwd attribute
91+
- [#2261][2261] Fix corefile module after pyelftools update
9192

9293
[2214]: https://github.com/Gallopsled/pwntools/pull/2214
9394
[2241]: https://github.com/Gallopsled/pwntools/pull/2241
95+
[2261]: https://github.com/Gallopsled/pwntools/pull/2261
9496

9597
## 4.10.0
9698

pwnlib/elf/corefile.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@
7676
from io import BytesIO, StringIO
7777

7878
import elftools
79-
from elftools.common.py3compat import bytes2str
8079
from elftools.common.utils import roundup
8180
from elftools.common.utils import struct_parse
8281
from elftools.construct import CString
@@ -94,6 +93,7 @@
9493
from pwnlib.util.fiddling import unhex
9594
from pwnlib.util.misc import read
9695
from pwnlib.util.misc import write
96+
from pwnlib.util.packing import _decode
9797
from pwnlib.util.packing import pack
9898
from pwnlib.util.packing import unpack_many
9999

@@ -134,12 +134,13 @@ def iter_notes(self):
134134
self.stream.seek(offset)
135135
# n_namesz is 4-byte aligned.
136136
disk_namesz = roundup(note['n_namesz'], 2)
137-
note['n_name'] = bytes2str(
138-
CString('').parse(self.stream.read(disk_namesz)))
139-
offset += disk_namesz
137+
with context.local(encoding='latin-1'):
138+
note['n_name'] = _decode(
139+
CString('').parse(self.stream.read(disk_namesz)))
140+
offset += disk_namesz
140141

141-
desc_data = bytes2str(self.stream.read(note['n_descsz']))
142-
note['n_desc'] = desc_data
142+
desc_data = _decode(self.stream.read(note['n_descsz']))
143+
note['n_desc'] = desc_data
143144
offset += roundup(note['n_descsz'], 2)
144145
note['n_size'] = offset - note['n_offset']
145146
yield note

pwnlib/util/packing.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,6 +1065,9 @@ def _encode(s):
10651065
return s.encode(context.encoding)
10661066

10671067
def _decode(b):
1068+
if isinstance(b, (str, six.text_type)):
1069+
return b # already text
1070+
10681071
if context.encoding == 'auto':
10691072
try:
10701073
return b.decode('utf-8')

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ requires-python = ">=2.7"
3636
dependencies = [
3737
"paramiko>=1.15.2",
3838
"mako>=1.0.0",
39-
"pyelftools>=0.2.4",
39+
"pyelftools>=0.24, <0.30; python_version < '3'",
40+
"pyelftools>=0.24; python_version >= '3'",
4041
"capstone>=3.0.5rc2", # see Gallopsled/pwntools#971, Gallopsled/pwntools#1160
4142
"ropgadget>=5.3",
4243
"pyserial>=2.7",

0 commit comments

Comments
 (0)