Bug #2825: Unix Socket Ignored in mysql_connect()

From: Date: Wed, 24 Nov 1999 20:06:10 +0000
Subject: Bug #2825: Unix Socket Ignored in mysql_connect()
Groups: php.dev 
Request: Send a blank email to php-dev+get-13080@lists.php.net to get a copy of this message
From: jadiel@thevision.net Operating system: Linux 2.0.xx PHP version: 3.0.12 PHP Bug Type: MySQL related Bug description: Unix Socket Ignored in mysql_connect() 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; }

« previous php.dev (#13080) next »