php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #63886 PHP crashes when quoting string with PDO and using mysqlnd_ms
Submitted: 2013-01-02 19:20 UTC Modified: 2013-02-04 17:48 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: rubs33 at gmail dot com Assigned: mysql (profile)
Status: Closed Package: MySQL related
PHP Version: 5.5.0alpha2 OS: Fedora Linux 17 x86_64
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: rubs33 at gmail dot com
New email:
PHP Version: OS:

 

 [2013-01-02 19:20 UTC] rubs33 at gmail dot com
Description:
------------
I am testing mysqlnd_ms plugin and I have just noticed that PHP crashes when I use PDO::quote method at these conditions:
1 - Enable mysqlnd_ms
2 - At PDO constructor call, specify a host to a replicated database and specify an invalid charset.

The plugin itself is working fine for its propose. The problem is with the "quote" method, that might been affected by the plugin.

Versions:
PHP: 5.5.0alpha2
mysqlnd: 5.0.11-dev - 20120503
mysqlnd_ms: 1.4.2 (10402)
MySQL: 5.5.28

Note: when I run the test script with a non replicated database, I get the expected result and PHP did not crash.

Test script:
---------------
<?php
$pdo = new PDO('mysql:host=myapp;dbname=test;charset=x', 'rubens', '123');
$value = $pdo->quote('a');
var_dump($value);
?>


Expected result:
----------------
string(3) "'a'"

Actual result:
--------------
Segmentation fault (core dumped)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-01-30 15:36 UTC] uw@php.net
-Package: mysqlnd_ms +Package: MySQL related -Assigned To: +Assigned To: mysql
 [2013-01-30 15:36 UTC] uw@php.net
Hi, 

this should be a follow up crash due to a mysqlnd bug. The connection is in an invalid state. You should not be allowed to connect at all.

Albeit the charset is invalid, you can connect if using mysqlnd:

bash: /home/nixnutz/git/superhero/php-srcphp: Datei oder Verzeichnis nicht gefunden
nixnutz@linux-0v4u:~/php-src/pecl/mysqlnd_ms/trunk> php -d mysqlnd.debug="d:t:O,/tmp/mysqlnd.trace" -r '$pdo = new PDO("mysql:host=127.0.0.1;port=3307;dbname=test;charset=x"); var_dump($pdo->quote("a"));'
string(3) "'a'"


ixnutz@linux-0v4u:~/php-src/pecl/mysqlnd_ms/trunk> php -i | grep pdo
Configure Command =>  './configure'  '--with-mysql=mysqlnd' '--with-mysqli=mysqlnd' '--with-pdo-mysql=mysqlnd' '--enable-debug' '--disable-pear'
API Extensions => pdo_mysql,mysqli,mysql
pdo_mysql
pdo_mysql.debug => no value => no value
pdo_mysql.default_socket => /tmp/mysql.sock => /tmp/mysql.sock


However, if using libmysql one gets an error as I'd expect it:

nixnutz@linux-0v4u:~/php-src/pecl/mysqlnd_ms/trunk> /home/nixnutz/git/superhero/php-src/sapi/cli/php -d mysqlnd.debug="d:t:O,/tmp/mysqlnd.trace" -r '$pdo = new PDO("mysql:host=127.0.0.1;port=3307;dbname=test;charset=x"); var_dump($pdo->quote("a"));'
Character set 'x' is not a compiled character set and is not specified in the '/home/nixnutz/ftp/mysql-5.6/install/share/charsets/Index.xml' file

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] [2019] Can't initialize character set x (path: /home/nixnutz/ftp/mysql-5.6/install/share/charsets/)' in Command line code:1
Stack trace:
#0 Command line code(1): PDO->__construct('mysql:host=127....')
#1 {main}
  thrown in Command line code on line 1
nixnutz@linux-0v4u:~/php-src/pecl/mysqlnd_ms/trunk>  /home/nixnutz/git/superhero/php-src/sapi/cli/php -i | grep pdo
Configure Command =>  './configure'  '--with-mysql=mysqlnd' '--with-mysqli=mysqlnd' '--with-pdo-mysql=/home/nixnutz/ftp/mysql-5.6/install/bin/mysql_config' '--enable-debug' '--disable-pear'
pdo_mysql
pdo_mysql.default_socket => /tmp/mysql.sock => /tmp/mysql.sock
pdo_sqlite


I'd say: Andrey, please have a look...

Ulf

PS: No mysqlnd package in select box?
 [2013-01-30 16:34 UTC] uw@php.net
Automatic comment from SVN on behalf of uw
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=329374
Log: PDO and invalid charset bug 63886
 [2013-02-04 14:54 UTC] andrey@php.net
-Status: Assigned +Status: Feedback
 [2013-02-04 14:54 UTC] andrey@php.net
Please try using this snapshot:

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

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

Please try with updated PHP - from snaps.php.net . The fix was just commited. The next snapshot should have it.
 [2013-02-04 17:41 UTC] rubs33 at gmail dot com
-Status: Feedback +Status: Assigned
 [2013-02-04 17:41 UTC] rubs33 at gmail dot com
It works for me.

When I try to connect to a database using an invalid charset, it throws a PDOException.

Thanks.
 [2013-02-04 17:48 UTC] rubs33 at gmail dot com
I think I was supposed to close this bug.
 [2013-02-04 17:48 UTC] rubs33 at gmail dot com
-Status: Assigned +Status: Closed
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Wed Jun 26 14:01:25 2019 UTC