php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #50690 putenv() does not assign values to env. vars when the value is one character
Submitted: 2010-01-08 01:35 UTC Modified: 2010-01-24 14:29 UTC
Votes:2
Avg. Score:3.5 ± 0.5
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:1 (50.0%)
From: php at keithtyler dot com Assigned: pajoye (profile)
Status: Closed Package: PHP options/info functions
PHP Version: 5.3.1 OS: Windows XP
Private report: No CVE-ID: None
 [2010-01-08 01:35 UTC] php at keithtyler dot com
Description:
------------
In PHP 5.3.1, a putenv() call with a one character value does not assign the value to the variable -- however it does create the variable.

It doesn't matter what type of character it is (alpha, numeric, or other).

A workaround is to add a space character before or after the value, e.g.:

putenv("bar= x");
putenv("bar=x ");

(...as long as this space does not cause problems for the consumers of the variable as it will be part of the string value.)

Reproduce code:
---------------
<?php
putenv("foo=ab");
putenv("bar=c");
var_dump(getenv("foo"));
var_dump(getenv("bar"));
var_dump(getenv("thisvardoesnotexist"));
?>

Expected result:
----------------
We would expect the output to be:

string(2) "ab"
string(1) "c"
bool(false)

which it does under PHP 5.3.0.

Actual result:
--------------
string(2) "ab"
string(0) ""
bool(false)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-01-08 07:02 UTC] jani@php.net
Please try using this snapshot:

  http://snaps.php.net/php5.3-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/

It's either fixed or win32 only issue since I can't reproduce this under linux using latest SVN checkout.
 [2010-01-16 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2010-01-23 01:08 UTC] v-ryanbi at microsoft dot com
Bug still exhibited.

SVN revision 293853 Clean (checked out 2010-01-22 10:15 PST)
Compiled on Windows 2008 R2 / VC9 (VS 2010 Express)
 [2010-01-24 13:49 UTC] svn@php.net
Automatic comment from SVN on behalf of pajoye
Revision: http://svn.php.net/viewvc/?view=revision&revision=293902
Log: - #50690, putenv does assign value when their length is one char
 [2010-01-24 14:29 UTC] pajoye@php.net
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 12:01:29 2024 UTC