|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2003-02-20 17:05 UTC] tbrown at baremetal dot com
the symptom is that with register_globals=on some variables are being incorrectly initialized.
This seems to be because the are being initialized from the environment instead from _POST
The environment is messed up, because the values passed to putenv() are being free'd an the memory is being recycled... it happens that the contents of the POST data are being copied into that location... e.g.
username=admin&password=password&LOGIN=+++Login+++
this shows up as an environment variable username, with the value admin&password=password&LOGIN=+++Login+++
which stomps on the POST value of "admin" ...
the fix seems to be
cvs diff -u sapi/cgi/cgi_main.c
Index: sapi/cgi/cgi_main.c
===================================================================
RCS file: /repository/php4/sapi/cgi/cgi_main.c,v
retrieving revision 1.190.2.9.4.2
diff -u -u -r1.190.2.9.4.2 cgi_main.c
--- sapi/cgi/cgi_main.c 15 Feb 2003 22:56:04 -0000 1.190.2.9.4.2
+++ sapi/cgi/cgi_main.c 20 Feb 2003 23:04:14 -0000
@@ -388,7 +388,7 @@
/* if cgi, or fastcgi and not found in fcgi env
check the regular environment */
putenv(buf);
- efree(buf);
+ /* Not safe! and in CGI, not a leak: efree(buf); */
return 0;
}
although I don't know enough about fast-cgi to know if that is a memory leak or not...
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Dec 07 19:00:02 2025 UTC |
On the problem machine, this is enough to reproduce the problem... it is fairly finicky though, as to be expected for a memory layout issue... the spaces in the submit button value are significant... <?php if ($username) { // system("/var/www/cgi-bin/printenv"); print "ENV[username] = $_ENV[username] <br>\n"; print "POST[username] = $_POST[username] <br>\n"; } ?> <form method=post> <input name=username value=admin8020> <input name=password value=password> <input type="submit" name="LOGIN" value=" Login "> </form> the result is. ENV[username] = admin&password=password&LOGIN=+++Login+++ POST[username] = admin