|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2000-03-20 02:41 UTC] rasmus at cvs dot php dot net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Nov 03 01:00:01 2025 UTC |
I've attached a small patch to this message, apply it to mysql.c in the functions directory for PHP 3.0.12. Simple fix, you could probably hand apply it to 3.0.10 and 3.0.11. It really isn't a bug, it is a logic error. The bug in PHP 3.0.12 incorrectly ignores the socket value when specified with the port number. This prevents things like accessing multiple MySQL servers on a host that supports multiple MySQL servers. This can cause major problems for the unaware. That is, you could corrupt your MySQL database. In my case, I have 5 MySQL servers running on the same host. Each has a different port and different unix socket. I can specify the port, PHP will connect but will use the default socket even when I specify the socket also. Additionally, I scanned the Zend source and it appears that Zend doesn't even address the socket issue, it specifies the default socket in all mysql_connect calls, this can also pose a serious problem if more than one MySQL server is running on the same host, corrupted database galore. My question about Zend is does it handle setting the unix socket for MySQL connections differently, otherwise this is a serious error that should be addressed. I can't seem to find any documentation on Zend, I'm assuming that mysql_connect() is expected to have same functionality as PHP 3.0.12. Thanks, Jose Diff File: *** php-3.0.12/functions/mysql.c Sun Jul 4 10:30:42 1999 --- php-3.0.12.socketfixed/functions/mysql.c Wed Nov 24 10:07:55 1999 *************** *** 386,392 **** #if APACHE void (*handler) (int); #endif ! char *user,*passwd,*host,*socket = NULL,*tmp; char *hashed_details; int hashed_details_length,port = 0; MYSQL *mysql; --- 386,392 ---- #if APACHE void (*handler) (int); #endif ! char *user,*passwd,*host,*socket = NULL,*tmp,*tmp2; char *hashed_details; int hashed_details_length,port = 0; MYSQL *mysql; *************** *** 466,471 **** --- 466,476 ---- tmp++; if (tmp[0] != '/') { port = atoi(tmp); + if (tmp2=strchr(tmp,':')) { + *tmp2=0 ; + tmp2++ ; + socket = tmp2 ; + } } else { socket = tmp; }