xref: /php-src/ext/pdo_mysql/tests/bug_61755.phpt (revision 4bb75d56)
1--TEST--
2Bug #61755 (A parsing bug in the prepared statements can lead to access violations)
3--EXTENSIONS--
4pdo_mysql
5--SKIPIF--
6<?php
7require_once __DIR__ . '/inc/mysql_pdo_test.inc';
8MySQLPDOTest::skip();
9?>
10--FILE--
11<?php
12require_once __DIR__ . '/inc/mysql_pdo_test.inc';
13$db = MySQLPDOTest::factory();
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--EXPECT--
35NULL-Byte before first placeholder:
36Length of item 0: 3, Value of item 1: c
37
38Open comment:
39Error code: 42000
40
41done!
42