From: Debian Qt/KDE Maintainers Date: Sun, 14 Jul 2024 15:35:58 +0000 (+0300) Subject: QSQL/ODBC: fix regression (trailing NUL) X-Git-Tag: archive/raspbian/5.15.13+dfsg-3+rpi1^2~21 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=e4938934ae0fddacab34715809c7a09f3006b382;p=qtbase-opensource-src.git QSQL/ODBC: fix regression (trailing NUL) Origin: upstream, https://code.qt.io/cgit/qt/qtbase.git/commit/?id=9020034b3b6a3a81 Last-Update: 2023-06-30 When we fixed the callers of toSQLTCHAR() to use the result's size() instead of the input's (which differ, if sizeof(SQLTCHAR) != 2), we exposed callers to the append(0), which changes the size() of the result QVLA. Callers that don't rely on NUL-termination (all?) now saw an additional training NUL. Fix by not NUL-terminating, and changing the only user of SQL_NTS to use an explicit length. Gbp-Pq: Name sql_odbc_fix_unicode_check.diff --- diff --git a/src/plugins/sqldrivers/odbc/qsql_odbc.cpp b/src/plugins/sqldrivers/odbc/qsql_odbc.cpp index 4af6ee4bd..cb7e7a629 100644 --- a/src/plugins/sqldrivers/odbc/qsql_odbc.cpp +++ b/src/plugins/sqldrivers/odbc/qsql_odbc.cpp @@ -125,7 +125,6 @@ inline static QVarLengthArray toSQLTCHAR(const QString &input) { QVarLengthArray result; toSQLTCHARImpl(result, input); - result.append(0); // make sure it's null terminated, doesn't matter if it already is, it does if it isn't. return result; } @@ -2119,7 +2118,8 @@ void QODBCDriverPrivate::checkUnicode() QLatin1String("select 'test' from dual"), }; for (const auto &statement : statements) { - r = SQLExecDirect(hStmt, toSQLTCHAR(statement).data(), SQL_NTS); + auto encoded = toSQLTCHAR(statement); + r = SQLExecDirect(hStmt, encoded.data(), SQLINTEGER(encoded.size())); if (r == SQL_SUCCESS) break; }