Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug?] FileStructure.struntil one byte shorter for no apparent reason? #2403

Open
goreil opened this issue May 7, 2024 · 0 comments
Open

Comments

@goreil
Copy link
Contributor

goreil commented May 7, 2024

The function FileStructure.struntil returns one byte less for no apparent reason. For example, when I request fp.struntil("flags") I expect to get all 8 bytes of the flags struct.

Tested in the pwntools:stable dockercontainer

pwntools@541d39158471:/$ python
Python 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from pwn import *
>>> context.clear(arch="amd64")
>>> fp = FileStructure()
>>> payload = fp.struntil("flags")
>>> len(payload)
7

-> I only got 7 bytes

Reason

In pwnlib/filepointer.py the last byte gets truncated

    def struntil(self,v):
[...]
        return structure[:-1]

Proposed fix

Either remove the [:-1] or write it in the documentation why the function is supposed to behave this way.

@peace-maker peace-maker linked a pull request May 15, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant