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

Fix corefile environment variables and speed up ELF.string() #1055

Merged
merged 7 commits into from
Oct 24, 2017

Conversation

zachriggle
Copy link
Member

@zachriggle zachriggle commented Oct 15, 2017

I'm not sure how the logic for environment variables was supposed to work, but it was broken.

This fixes the environment, and ensures that embedded = bytes in the env value (e.g. FOO=BAR=BAZ) work correctly.

A performance enhancement for ELF.string(...) which reads a page at a time, rather than a byte at a time.

A change to corefile lifecycles such that if rename_corefiles=True, the original is deleted. This is to avoid the issue where core_pattern=core and there may be a race condition when two corefiles are created rapidly.

Some doctests were added to test these edge cases, including a corrupted stack.

@zachriggle zachriggle added the bug label Oct 15, 2017
@zachriggle zachriggle added this to the 3.10.0 milestone Oct 15, 2017
@zachriggle zachriggle self-assigned this Oct 15, 2017
@zachriggle
Copy link
Member Author

Technically this is present in the 3.9 release as well, but the 3.10 release is coming up in a few days so we may as well just defer cutting a new release.

I'm still merging this to stable and merging through beta and dev.

@zachriggle
Copy link
Member Author

These doctests definitely work locally for me, I'm not sure why they're failing.

@zachriggle
Copy link
Member Author

So it looks like the issue is that we're still getting the old corefile.

**********************************************************************
File "elf/corefile.rst", line ?, in default
Failed example:
    core.pid, core.path, core.exe, io.executable
Expected nothing
Got:
    (6946, '/home/travis/build/Gallopsled/core.6946', Mapping('/tmp/pwn-asm-yA9YlO/step3', start=0x10000000, stop=0x10001000, size=0x1000, flags=0x7), '/tmp/pwn-asm-yA9YlO/step3')
**********************************************************************
File "elf/corefile.rst", line ?, in default
Failed example:
    core.pid, core.path, core.exe, io.executable
Expected nothing
Got:
    (6946, '/home/travis/build/Gallopsled/core.6946', Mapping('/tmp/pwn-asm-yA9YlO/step3', start=0x10000000, stop=0x10001000, size=0x1000, flags=0x7), '/tmp/pwn-asm-ERFKdo/step3')
**********************************************************************

Note that the exe path is different from what the corefile thinks it should be -- ERFKdo vs yA9YlO.

I've fixed this in c491be4 by unlinking the original when we do the rename.

@zachriggle
Copy link
Member Author

Coverage and Travis pass. Codacy is disabled for stable (?), so I'm merging.

@zachriggle zachriggle merged commit 74a5876 into Gallopsled:stable Oct 24, 2017
@zachriggle zachriggle deleted the corefile-environment-fixes branch October 24, 2017 04:45
@zachriggle zachriggle restored the corefile-environment-fixes branch March 21, 2019 17:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant