Skip to content

Commit

Permalink
Merge branch 'stable' into beta
Browse files Browse the repository at this point in the history
  • Loading branch information
heapcrash committed Jun 27, 2020
2 parents 8cd4d2b + 0acf366 commit 21c7864
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,13 @@ To be released on Jun 5, 2020.
[fecf9f]: http://github.com/Gallopsled/pwntools/commit/fecf9f
[1454]: https://github.com/Gallopsled/pwntools/pull/1454

## 4.1.4 (`stable`)
## 4.1.5 (`stable`)

- [#1517][1517] flat(..., filler=) is fixed for `str` values and Python2 `bytes`

[1517]: https://github.com/Gallopsled/pwntools/pull/1517

## 4.1.4

- [#1698][1609] Fix issues in `packing.flat` with mis-ordred fields

Expand Down
7 changes: 6 additions & 1 deletion pwnlib/util/packing.py
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,9 @@ def flat(*args, **kwargs):
You can customize this by providing an iterable or method for the ``filler``
argument.
>>> flat({12: 'XXXX'}, filler = (ord('A'), ord('B')), length = 20)
>>> flat({12: 'XXXX'}, filler = b'_', length = 20)
b'____________XXXX____'
>>> flat({12: 'XXXX'}, filler = b'AB', length = 20)
b'ABABABABABABXXXXABAB'
Nested dictionaries also work as expected.
Expand All @@ -720,6 +722,9 @@ def flat(*args, **kwargs):
filler = kwargs.pop('filler', cyclic.de_bruijn())
length = kwargs.pop('length', None)

if isinstance(filler, str):
filler = bytearray(six.ensure_binary(filler))

if kwargs != {}:
raise TypeError("flat() does not support argument %r" % kwargs.popitem()[0])

Expand Down

0 comments on commit 21c7864

Please sign in to comment.