-
Notifications
You must be signed in to change notification settings - Fork 584
Add a configure probe for setenv() and enable PERL_USE_SAFE_PUTENV on the platforms that have it #19514
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
Conversation
PS. Apart from the usual platforms, I've tested this change on AIX and HP-UX. There were no problems. |
This is needed for Perl/perl5#19514
Looks like the test failure was due to the trailing NUL byte in Can you rebase this on current blead and try again? It's too close to a 5.36 release to put this in now, but it would be nice to get it lined up ready to start in 5.37.1. |
See #19504 (comment) for details on the null byte issue with $0. |
The new test has actually exposed a real problem in my branch. The cause of the failure was that I have updated the branch with a more comprehensive fix and also some refactoring, see the commit messages for more details. The non- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the Configure
part, I see that this probe already exists upstream, but has not been included because it isnt/wasnt used. If I would add it it metaconfig.h
and regenerate Configure
and friends, it'll include the original documentation too.
FWIW, here is the part of the original code that is already available:
(somewhat modified to fit) |
I don't quite understand. As far as I can tell, there are no |
There are no |
Sure, that works too. |
- Early return is much better than wrapping the whole function with if(). - Remove pointless (void) casts. - Move variable declarations closer to their first use. - Normalize indentation.
This allows us to overwrite the original environ when $0 is being set, which means that enabling PERL_USE_SAFE_PUTENV will no longer decrease the maximum length of $0 on some platforms.
Now environ isn't owned by Perl and calling setenv/putenv in XS code will no longer result in memory corruption. Fixes Perl#19399
environ is managed by the C runtime, while we are using the system APIs directly.
The purpose of PL_origenviron is to preserve the earliest known value of environ, which is a global. All interpreters should share it.
Fixes #19399