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

Force ELF.path to be of type string #2174

Merged
merged 1 commit into from May 21, 2023
Merged

Conversation

jamestiotio
Copy link
Contributor

This fixes #2166.

This PR forces the path class variable of the ELF class to be of type string, even if a byte string argument is supplied. This also makes the implementation consistent with the documentation, which states that ELF.path is of type str.

Signed-off-by: James Raphael Tiovalen jamestiotio@gmail.com

@Arusekk
Copy link
Member

Arusekk commented Mar 22, 2023

This breaks tests for py2.

@jamestiotio
Copy link
Contributor Author

@Arusekk Commit 1491f21 should fix the breaking Python 2.7 test.

Seems like we have to call both .decode() and str() for self.path to be a real string due to different types between Python 2 and 3.

@Arusekk
Copy link
Member

Arusekk commented Mar 22, 2023

This won't work in py2 with bytes > b'\x7f'. See context._encode or context._need_bytes etc.

This commit forces the `path` class variable of the `ELF` class to be of
type string, even if a byte string argument is passed. This also makes
the implementation consistent with the documentation, which states that
`ELF.path` is of type `str`.

Fixes Gallopsled#2166

Signed-off-by: James Raphael Tiovalen <jamestiotio@gmail.com>
@jamestiotio
Copy link
Contributor Author

This won't work in py2 with bytes > b'\x7f'. See context._encode or context._need_bytes etc.

Hmm okay, I have modified the code to use the packing._need_text function instead. It should take care of the various different encodings.

@Arusekk Arusekk added this to the 4.10.0 milestone Apr 26, 2023
@Arusekk Arusekk merged commit 60af3a2 into Gallopsled:dev May 21, 2023
9 of 10 checks passed
Arusekk pushed a commit that referenced this pull request May 21, 2023
This commit forces the `path` class variable of the `ELF` class to be of
type string, even if a byte string argument is passed. This also makes
the implementation consistent with the documentation, which states that
`ELF.path` is of type `str`.

Fixes #2166

Cherry-picked from 60af3a2

Signed-off-by: James Raphael Tiovalen <jamestiotio@gmail.com>
gogo2464 pushed a commit to gogo2464/pwntools that referenced this pull request Sep 10, 2023
This commit forces the `path` class variable of the `ELF` class to be of
type string, even if a byte string argument is passed. This also makes
the implementation consistent with the documentation, which states that
`ELF.path` is of type `str`.

Fixes Gallopsled#2166

Signed-off-by: James Raphael Tiovalen <jamestiotio@gmail.com>
gogo2464 pushed a commit to gogo2464/pwntools that referenced this pull request Sep 10, 2023
This commit forces the `path` class variable of the `ELF` class to be of
type string, even if a byte string argument is passed. This also makes
the implementation consistent with the documentation, which states that
`ELF.path` is of type `str`.

Fixes Gallopsled#2166

Cherry-picked from 60af3a2

Signed-off-by: James Raphael Tiovalen <jamestiotio@gmail.com>
gogo2464 pushed a commit to gogo2464/pwntools that referenced this pull request Sep 10, 2023
This commit forces the `path` class variable of the `ELF` class to be of
type string, even if a byte string argument is passed. This also makes
the implementation consistent with the documentation, which states that
`ELF.path` is of type `str`.

Fixes Gallopsled#2166

Cherry-picked from 60af3a2

Signed-off-by: James Raphael Tiovalen <jamestiotio@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ROP doesn't work when ELF path is bytestring
2 participants