Skip to content

Patch for Bug #64544. - #313

Closed
keyurdg wants to merge 1 commit into
php:PHP-5.5from
keyurdg:PHP-5.5
Closed

keyurdg wants to merge 1 commit into
php:PHP-5.5from
keyurdg:PHP-5.5

Conversation

@keyurdg

@keyurdg keyurdg commented Mar 29, 2013

Copy link
Copy Markdown
Contributor

The process title change module keeps track of the locally allocated
environ, so it doesn't need to worry about when environ changes
underneath it, for example by putenv()/setenv()

The process title change module keeps track of the locally allocated
environ, so it doesn't need to worry about when environ changes
underneath it, for example by putenv()/setenv()
@keyurdg

keyurdg commented Mar 29, 2013

Copy link
Copy Markdown
Contributor Author

Merged this pull request.

@keyurdg keyurdg closed this Mar 29, 2013
@laruence

Copy link
Copy Markdown
Member

@keyurdg the frozen_environ is needed,, otherwise when a item in env is update, you will get invalid free.

<?php

putenv("HOME=/tmp");
var_dump(getenv("HOME"));

putenv("FOO=BAR");
var_dump(getenv("FOO"));

I will commit my patch.. thanks

@keyurdg

keyurdg commented Mar 29, 2013

Copy link
Copy Markdown
Contributor Author

@laruence Great catch, I now realized my mistake.

For anyone else curious: putenv() will create a whole new environment if the 'key' doesn't already exist in the current environment and replace the global variable "environ" with this newly created one. To correctly handle the free'ing around the environ allocated by ps_title, new_environ is needed.

Or if the key does exist, putenv() will replace the pointer in the global environ with the string pointer passed in. To ensure correctness, frozen_environ stores a list of all strings alloc'ed by ps_title.c and frees them all at the end.

@laruence

Copy link
Copy Markdown
Member

yes, and more important is, zif_putenv passes in a string that is emalloced, if cleanup_ps_args attempt to free it -> invalid free

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.

2 participants