xref: /PHP-7.1/ext/pdo_mysql/tests/bug_61755.phpt (revision 1b78aef4)
1--TEST--
2Bug #61755 (A parsing bug in the prepared statements can lead to access violations)
3--SKIPIF--
4<?php
5if (!extension_loaded('pdo') || !extension_loaded('pdo_mysql')) die('skip not loaded');
6require dirname(__FILE__) . '/config.inc';
7require dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
8PDOTest::skip();
9?>
10--FILE--
11<?php
12require dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
13$db = PDOTest::test_factory(dirname(__FILE__) . '/common.phpt');
14
15$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
16
17echo "NULL-Byte before first placeholder:\n";
18$s = $db->prepare("SELECT \"a\0b\", ?");
19$s->bindValue(1,"c");
20$s->execute();
21$r = $s->fetch();
22echo "Length of item 0: ".strlen($r[0]).", Value of item 1: ".$r[1]."\n";
23
24echo "\nOpen comment:\n";
25try {
26    $s = $db->prepare("SELECT /*");
27    $s->execute();
28} catch (Exception $e) {
29    echo "Error code: ".$e->getCode()."\n";
30}
31
32echo "\ndone!\n";
33?>
34--EXPECTF--
35NULL-Byte before first placeholder:
36Length of item 0: 3, Value of item 1: c
37
38Open comment:
39Error code: 42000
40
41done!
42