Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Patch for Bug #64544. #313

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
2 participants
Contributor

keyurdg commented Mar 29, 2013

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 Patch for Bug #64544.
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()
5bf6323
Contributor

keyurdg commented Mar 29, 2013

Merged this pull request.

@keyurdg keyurdg closed this Mar 29, 2013

Owner

laruence commented Mar 29, 2013

@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

Contributor

keyurdg commented Mar 29, 2013

@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.

Owner

laruence commented Mar 30, 2013

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

@keyurdg keyurdg deleted the unknown repository branch Aug 14, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment