|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2000-07-30 09:43 UTC] zak@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 12:00:01 2025 UTC |
In php_mysql.c:444 If mysql_connect($host) is called and $host="foo:1234" then the variable $host will be truncated at the colon. The code jams a NULL at this position: if (host && (tmp=strchr(host,':'))) { *tmp=0; tmp++; port = atoi(tmp); } else { port = MySG(default_port); } I think the code should copy the host part of the string to a new variable rather than corrupting the user variable. <? $user="dbuser"; $passwd="dbpasswd"; $host='127.0.0.1:63306'; echo "host is \"$host\"<br>"; if (! $cid = mysql_connect($host,$user,$passwd)) { echo "FAIL connect($host,$user,$passwd): (" . mysql_error() . ") LOSER"; } else { echo "OK! host=\"$host\" WINNER"; } ?> And when I run the code, note below that the rest of the "echo" statement after the truncated host part is not rendered, due to the NULL in the string. Connecting manually to the server and going a HTTP GET shows the NULL in the string, but the string is still damaged. host is "127.0.0.1:63306" OK! host="127.0.0.1 This is also done in today's 4.0b CVS.