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