Fix the new --query-invariants option on fuzzcheck so that it does not

use an unprotected sqlite3_value object as an argument to sqlite3_value_int64().

FossilOrigin-Name: d9f820151d74a690b5fa560597a5b3ace20165a112e1b58cb4a7c47b42745643
This commit is contained in:
drh 2022-06-17 12:25:33 +00:00
parent 2a7aff93ed
commit 6efabd6cd3
3 changed files with 21 additions and 22 deletions

View File

@ -1,5 +1,5 @@
C Avoid\somitting\sthe\srhs\sof\sFULL\sJOINs\sin\scases\swhere\sit\sis\sonly\scorrect\sto\somit\sthe\srhs\sof\sa\sLEFT\sJOIN.
D 2022-06-17T11:39:24.504
C Fix\sthe\snew\s--query-invariants\soption\son\sfuzzcheck\sso\sthat\sit\sdoes\snot\nuse\san\sunprotected\ssqlite3_value\sobject\sas\san\sargument\sto\ssqlite3_value_int64().
D 2022-06-17T12:25:33.660
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@ -1097,7 +1097,7 @@ F test/fuzzdata8.db ca9a97f401b06b0d5376139ec7e1f9e773e13345a9a2d9ccc0032cdbfede
F test/fuzzer1.test 3d4c4b7e547aba5e5511a2991e3e3d07166cfbb8
F test/fuzzer2.test a85ef814ce071293bce1ad8dffa217cbbaad4c14
F test/fuzzerfault.test f64c4aef4c9e9edf1d6dc0d3f1e65dcc81e67c996403c88d14f09b74807a42bc
F test/fuzzinvariants.c 0a8e98662b0ab765881c4094843c1cb4db07dced13006d8572dccf4004b2923f
F test/fuzzinvariants.c e7b413a2526d9f702a2bfea5cbe5bdb7cb88c89b433e3e8ad931888bb5597bd0
F test/gcfault.test dd28c228a38976d6336a3fc42d7e5f1ad060cb8c
F test/gencol1.test cc0dbb0ee116e5602e18ea7d47f2a0f76b26e09a823b7c36ef254370c2b0f3c1
F test/genesis.tcl 1e2e2e8e5cc4058549a154ff1892fe5c9de19f98
@ -1978,8 +1978,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
P 447e62a0946f5d77b7358adcabaeb23a7012cdfbfa1ef6082734cd9b45b2699d
R 4a775b1d5ba6396498691341f48a10ac
U dan
Z 4f025e5a7e8dcede4b711630a37a27ba
P f23a429d4153518d37387e121f22a30b22e2b31e126ad168e72049a96be86269
R 10f66102aac19f279bc67099d1ccf16a
U drh
Z 8cec7a3e8591667bdea33d0479acc5f3
# Remove this line to create a well-formed Fossil manifest.

View File

@ -1 +1 @@
f23a429d4153518d37387e121f22a30b22e2b31e126ad168e72049a96be86269
d9f820151d74a690b5fa560597a5b3ace20165a112e1b58cb4a7c47b42745643

View File

@ -29,7 +29,7 @@
/* Forward references */
static char *fuzz_invariant_sql(sqlite3_stmt*, int);
static int sameValue(sqlite3_value*,sqlite3_value*);
static int sameValue(sqlite3_stmt*,int,sqlite3_stmt*,int);
static void reportInvariantFailed(sqlite3_stmt*,sqlite3_stmt*,int);
/*
@ -97,8 +97,7 @@ int fuzz_invariant(
}
while( (rc = sqlite3_step(pTestStmt))==SQLITE_ROW ){
for(i=0; i<nCol; i++){
if( !sameValue(sqlite3_column_value(pStmt,i),
sqlite3_column_value(pTestStmt,i)) ) break;
if( !sameValue(pStmt, i, pTestStmt, i) ) break;
}
if( i>=nCol ) break;
}
@ -211,29 +210,29 @@ static char *fuzz_invariant_sql(sqlite3_stmt *pStmt, int iCnt){
/*
** Return true if and only if v1 and is the same as v2.
*/
static int sameValue(sqlite3_value *v1, sqlite3_value *v2){
static int sameValue(sqlite3_stmt *pS1, int i1, sqlite3_stmt *pS2, int i2){
int x = 1;
if( sqlite3_value_type(v1)!=sqlite3_value_type(v2) ) return 0;
switch( sqlite3_value_type(v1) ){
if( sqlite3_column_type(pS1,i1)!=sqlite3_column_type(pS2,i2) ) return 0;
switch( sqlite3_column_type(pS1,i1) ){
case SQLITE_INTEGER: {
x = sqlite3_value_int64(v1)==sqlite3_value_int64(v2);
x = sqlite3_column_int64(pS1,i1)==sqlite3_column_int64(pS2,i2);
break;
}
case SQLITE_FLOAT: {
x = sqlite3_value_double(v1)==sqlite3_value_double(v2);
x = sqlite3_column_double(pS1,i1)==sqlite3_column_double(pS2,i2);
break;
}
case SQLITE_TEXT: {
const char *z1 = (const char*)sqlite3_value_text(v1);
const char *z2 = (const char*)sqlite3_value_text(v2);
const char *z1 = (const char*)sqlite3_column_text(pS1,i1);
const char *z2 = (const char*)sqlite3_column_text(pS2,i2);
x = ((z1==0 && z2==0) || (z1!=0 && z2!=0 && strcmp(z1,z1)==0));
break;
}
case SQLITE_BLOB: {
int len1 = sqlite3_value_bytes(v1);
const unsigned char *b1 = sqlite3_value_blob(v1);
int len2 = sqlite3_value_bytes(v2);
const unsigned char *b2 = sqlite3_value_blob(v2);
int len1 = sqlite3_column_bytes(pS1,i1);
const unsigned char *b1 = sqlite3_column_blob(pS1,i1);
int len2 = sqlite3_column_bytes(pS2,i2);
const unsigned char *b2 = sqlite3_column_blob(pS2,i2);
if( len1!=len2 ){
x = 0;
}else if( len1==0 ){