From 8da5d35ae8ef0342adddf11705cad8ed60f871ad Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Sun, 8 Dec 2019 11:48:46 +0100 Subject: [PATCH] Fix out of bounds read in tst_qsqlquery MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I87962a17b13d212fa7fcc30bcd40174f2a7cded0 Reviewed-by: MÃ¥rten Nordheim --- tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp index 1a5aa63489..4c3749eaee 100644 --- a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp +++ b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp @@ -1846,7 +1846,8 @@ void tst_QSqlQuery::precision() QSKIP("DB unable to store high precision"); const QString qtest_precision(qTableName("qtest_precision", __FILE__, db)); - static const char* precStr = "1.2345678901234567891"; + static const char precStr[] = "1.2345678901234567891"; + const int precStrLen = sizeof(precStr); { // need a new scope for SQLITE @@ -1868,7 +1869,7 @@ void tst_QSqlQuery::precision() if ( !val.startsWith( "1.2345678901234567891" ) ) { int i = 0; - while ( precStr[i] != 0 && *( precStr + i ) == val[i].toLatin1() ) + while ( i < precStrLen && i < val.size() && precStr[i] != 0 && *( precStr + i ) == val[i].toLatin1() ) i++; // MySQL and TDS have crappy precisions by default