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
del os.environ[key] ignores errors #57624
Comments
os.unsetenv(name) encodes name to UTF-8. I think that the ANSI code page (or another code page?) should be used. |
But... there is no os.unsetenv on Windows! |
Correct, even unsetenv() doesn't exist on Windows: putenv() can be used to unset a variable using an empty value. And it's exactly what Python does. It is confusing because posix_unsetenv() is not build on Windows, but it contains code specific for Windows. While testing del os.environ[key], I found another bug: del os.environ['x'*50000] does crash Python on Windows. Attached patch (for Python 3.3) does:
The Windows bug does affect Python 2.7 too. "Check if unsetenv() failed on UNIX" change may be skipped on Python 2.7 and 3.2. |
New changeset 3e892f428278 by Victor Stinner in branch '3.2': New changeset aa55b7dc43f7 by Victor Stinner in branch 'default': New changeset 53cf6f9f374e by Victor Stinner in branch '2.7': |
Oh, it looks like unsetenv() has no return value on Mac OS X Tiger: ./Modules/posixmodule.c: In function 'posix_unsetenv': |
And neither does FreeBSD < 7: Note that ignoring unsetenv() return value is a bad idea: We could maybe add a configure-time check. |
Oh yeah, I remember this critical (local) vulnerability!
Yes, it sounds like the best solution. |
Using broken_unsetenv.diff + autoconf, Python compiles correctly on Mac OS X Tiger. |
New changeset 1b83fd683e28 by Victor Stinner in branch 'default': |
New changeset 23ed66484ff2 by Charles-François Natali in branch 'default': |
Oh, thanks Charles François for your two patches. |
New changeset 26275a1c229c by Charles-François Natali in branch '3.2': New changeset bceb6aea8554 by Charles-François Natali in branch '3.2': |
New changeset 11bbeaf03894 by Charles-François Natali in branch '2.7': New changeset 99f5a0475ead by Charles-François Natali in branch '2.7': |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: