Skip to content

php 8.1.34 - Unit test failure #21176

@tharukaDacquia

Description

@tharukaDacquia

Description

The following code:
https://github.com/php/php-src/blob/PHP-8.5.3/ext/pdo_pgsql/tests/ghsa-8xr5-qppj-gvwj.phpt

--TEST--
#GHSA-8xr5-qppj-gvwj: NULL Pointer Derefernce for failed user input quoting
--EXTENSIONS--
pdo
pdo_pgsql
--SKIPIF--
<?php
require_once dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
require_once dirname(__FILE__) . '/config.inc';
PDOTest::skip();
?>
--FILE--
<?php
require_once dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
require_once dirname(__FILE__) . '/config.inc';
$db = PDOTest::test_factory(dirname(__FILE__) . '/common.phpt');
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);

$sql = "SELECT * FROM users where username = :username";
$stmt = $db->prepare($sql);

$p1 = "alice\x99";
var_dump($stmt->execute(['username' => $p1]));

?>
--EXPECT--
bool(false)

Resulted in this output:

========DIFF========
001+ Fatal error: Uncaught PDOException: SQLSTATE[22021]: Character not in repertoire: 7 ERROR:  invalid byte sequence for encoding "UTF8": 0x99 in /home/webuser/ext/pdo_pgsql/tests/ghsa-8xr5-qppj-gvwj.php:12
001- bool(false)
002+ Stack trace:
003+ #0 /home/webuser/ext/pdo_pgsql/tests/ghsa-8xr5-qppj-gvwj.php(12): PDOStatement->execute(Array)
004+ #1 {main}
005+   thrown in /home/webuser/ext/pdo_pgsql/tests/ghsa-8xr5-qppj-gvwj.php on line 12
========DONE========
FAIL #GHSA-8xr5-qppj-gvwj: NULL Pointer Derefernce for failed user input quoting [ext/pdo_pgsql/tests/ghsa-8xr5-qppj-gvwj.phpt]

But I expected this output instead:

Based on the unit test code as i think we can't expect `false` as expectation since we enabling `$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION)`

PHP Version

php 8.1.34

Operating System

Ubuntu 18.04

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions