xref: /PHP-8.4/ext/pdo_odbc/tests/gh16450.phpt (revision c9eafc19)
1--TEST--
2GH-16450 (PDO_ODBC can inject garbage into field values)
3--EXTENSIONS--
4pdo_odbc
5--SKIPIF--
6<?php
7$dbpath = __DIR__ . "/test.mdb";
8try {
9    new PDO("odbc:Driver={Microsoft Access Driver (*.mdb, *.accdb)};Dbq=$dbpath;Uid=Admin;Pwd=;");
10} catch (PDOException $ex) {
11    die("skip Cannot connect to MS Access database");
12}
13?>
14--FILE--
15<?php
16$dbpath = __DIR__ . "/test.mdb";
17$pdo = new PDO("odbc:Driver={Microsoft Access Driver (*.mdb, *.accdb)};Dbq=$dbpath;Uid=Admin;Pwd=;");
18
19$pdo->exec("CREATE TABLE gh16450 (Id INT, MyLongText LONGCHAR)");
20$pdo->exec(sprintf("INSERT INTO gh16450 VALUES (1, '%s')", str_repeat("_", 2048)));
21$pdo->exec(sprintf("INSERT INTO gh16450 VALUES (1, '%s')", str_repeat("_", 2049)));
22
23$stmt = $pdo->query("SELECT MyLongText FROM gh16450");
24var_dump($stmt->fetchColumn(0));
25var_dump($stmt->fetchColumn(0));
26?>
27--CLEAN--
28<?php
29$dbpath = __DIR__ . "/test.mdb";
30$pdo = new PDO("odbc:Driver={Microsoft Access Driver (*.mdb, *.accdb)};Dbq=$dbpath;Uid=Admin;Pwd=;");
31$pdo->exec("DROP TABLE gh16450");
32?>
33--EXPECT--
34string(2048) "________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________"
35string(2049) "_________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________"
36