Skip to content

Fix GH-8576: Bad interpretation of length when char is UTF-8 #8926

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions ext/pdo_firebird/firebird_statement.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,9 @@ static int firebird_stmt_describe(pdo_stmt_t *stmt, int colno) /* {{{ */
int colname_len;
char *cp;

if ((var->sqltype & ~1) == SQL_TEXT) {
var->sqltype = SQL_VARYING | (var->sqltype & 1);
}
colname_len = (S->H->fetch_table_names && var->relname_length)
? (var->aliasname_length + var->relname_length + 1)
: (var->aliasname_length);
Expand Down
30 changes: 30 additions & 0 deletions ext/pdo_firebird/tests/gh8576.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
--TEST--
GH-8576 (Bad interpretation of length when char is UTF-8)
--EXTENSIONS--
pdo_firebird
--SKIPIF--
<?php require 'skipif.inc'; ?>
--FILE--
<?php
require 'testdb.inc';

$dbh->exec("CREATE TABLE gh8576 (name CHAR(1) CHARACTER SET UTF8)");
$dbh->exec("INSERT INTO gh8576 VALUES ('A')");
$stmt = $dbh->query("SELECT * FROM gh8576");
var_dump($stmt->fetchAll());
?>
--EXPECT--
array(1) {
[0]=>
array(2) {
["NAME"]=>
string(1) "A"
[0]=>
string(1) "A"
}
}
--CLEAN--
<?php
require 'testdb.inc';
$dbh->exec("DROP TABLE gh8576");
?>