1--TEST-- 2Bug #41125 (PDO mysql + quote() + prepare() can result in segfault) 3--SKIPIF-- 4<?php 5require_once(__DIR__ . DIRECTORY_SEPARATOR . 'skipif.inc'); 6require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc'); 7MySQLPDOTest::skip(); 8 9$db = MySQLPDOTest::factory(); 10$row = $db->query('SELECT VERSION() as _version')->fetch(PDO::FETCH_ASSOC); 11$matches = array(); 12if (!preg_match('/^(\d+)\.(\d+)\.(\d+)/ismU', $row['_version'], $matches)) 13 die(sprintf("skip Cannot determine MySQL Server version\n")); 14 15$version = $matches[1] * 10000 + $matches[2] * 100 + $matches[3]; 16if ($version < 40100) 17 die(sprintf("skip Need MySQL Server 5.0.0+, found %d.%02d.%02d (%d)\n", 18 $matches[1], $matches[2], $matches[3], $version)); 19?> 20--FILE-- 21<?php 22require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc'); 23$db = MySQLPDOTest::factory(); 24$db->exec("DROP TABLE IF EXISTS test"); 25 26// And now allow the evil to do his work 27$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 1); 28$sql = "CREATE TABLE IF NOT EXISTS test(id INT); INSERT INTO test(id) VALUES (1); SELECT * FROM test; INSERT INTO test(id) VALUES (2); SELECT * FROM test;"; 29$stmt = $db->query($sql); 30do { 31 var_dump($stmt->fetchAll()); 32} while ($stmt->nextRowset()); 33 34print "done!"; 35?> 36--CLEAN-- 37<?php 38require __DIR__ . '/mysql_pdo_test.inc'; 39$db = MySQLPDOTest::factory(); 40$db->exec("DROP TABLE IF EXISTS test"); 41?> 42--EXPECT-- 43array(0) { 44} 45array(0) { 46} 47array(1) { 48 [0]=> 49 array(2) { 50 ["id"]=> 51 string(1) "1" 52 [0]=> 53 string(1) "1" 54 } 55} 56array(0) { 57} 58array(2) { 59 [0]=> 60 array(2) { 61 ["id"]=> 62 string(1) "1" 63 [0]=> 64 string(1) "1" 65 } 66 [1]=> 67 array(2) { 68 ["id"]=> 69 string(1) "2" 70 [0]=> 71 string(1) "2" 72 } 73} 74done! 75