From cea1dc279848f308d85ea34517fca2566861e40f Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 22 May 2015 23:39:29 +0000 Subject: [PATCH 1/3] Fix another bad assert() in btree - one that can be false on a corrupt database file. FossilOrigin-Name: 89f0bbfde4d86a7b15e93aab9c487b4355c6fb2d --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/btree.c | 3 ++- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index cc487cf384..c7cda0512f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sincorrect\svalidation\sof\sthe\ssize\sof\sthe\sBLOB\sreturned\sby\sa\sgeometry\nfunction\son\sthe\sRHS\sof\sa\sMATCH\soperator\sin\sRTree.\s\sThe\sold\scode\sworked\sfor\n64-bit\ssystems\s(by\schance)\sbut\sfails\son\s32-bit. -D 2015-05-22T23:17:28.381 +C Fix\sanother\sbad\sassert()\sin\sbtree\s-\sone\sthat\scan\sbe\sfalse\son\sa\scorrupt\sdatabase\nfile. +D 2015-05-22T23:39:29.128 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 0a6ae26396ec696221021780dffbb894ff3cead7 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -192,7 +192,7 @@ F src/auth.c b56c78ebe40a2110fd361379f7e8162d23f92240 F src/backup.c ff743689c4d6c5cb55ad42ed9d174b2b3e71f1e3 F src/bitvec.c 5eb7958c3bf65210211cbcfc44eff86d0ded7c9d F src/btmutex.c 45a968cc85afed9b5e6cf55bf1f42f8d18107f79 -F src/btree.c 0eb4eb39e75be6170f1e59f7d6aabedaefb19938 +F src/btree.c d2bf38cf256bd2fcaa9ed87f2f217167d849fc1b F src/btree.h 969adc948e89e449220ff0ff724c94bb2a52e9f1 F src/btreeInt.h 973a22a6fd61350b454ad614832b1f0a5e25a1e4 F src/build.c d5d9090788118178190c5724c19f93953b8c7a4e @@ -1278,7 +1278,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P c1814242e6ce035d486cfbad5a1f4b49aa8898f3 -R f01355780527736c645fe9d48d526152 +P 10cc44f5a63e6cadf6940bb7310a177ee7fa6ee2 +R 12583c8a4670388a5d60502757678b98 U drh -Z c568275ed97c21c4c01709075e3bc4ce +Z f1e1ea5567a0f5557363801842b88558 diff --git a/manifest.uuid b/manifest.uuid index 5d4569be1b..850b0dbfaf 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -10cc44f5a63e6cadf6940bb7310a177ee7fa6ee2 \ No newline at end of file +89f0bbfde4d86a7b15e93aab9c487b4355c6fb2d \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index 6b7da394ac..01ce974d75 100644 --- a/src/btree.c +++ b/src/btree.c @@ -6167,7 +6167,8 @@ static void rebuildPage( memcpy(pData, pCell, szCell[i]); put2byte(pCellptr, (pData - aData)); pCellptr += 2; - assert( szCell[i]==cellSizePtr(pPg, pCell) ); + assert( szCell[i]==cellSizePtr(pPg, pCell) || CORRUPT_DB ); + testcase( szCell[i]!=cellSizePtr(pPg,pCell) ); } /* The pPg->nFree field is now set incorrectly. The caller will fix it. */ From f9def06160fed660c99f964ade1cfe17dd902612 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 22 May 2015 23:45:56 +0000 Subject: [PATCH 2/3] Fix a bug in fuzzershell caused by an uninitialized local variable. FossilOrigin-Name: 745deab87adc378a5376aaa9451fb9485bc2f4c4 --- manifest | 12 ++++++------ manifest.uuid | 2 +- tool/fuzzershell.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index c7cda0512f..4d0c1f61ad 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sanother\sbad\sassert()\sin\sbtree\s-\sone\sthat\scan\sbe\sfalse\son\sa\scorrupt\sdatabase\nfile. -D 2015-05-22T23:39:29.128 +C Fix\sa\sbug\sin\sfuzzershell\scaused\sby\san\suninitialized\slocal\svariable. +D 2015-05-22T23:45:56.266 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 0a6ae26396ec696221021780dffbb894ff3cead7 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -1230,7 +1230,7 @@ F tool/diffdb.c 7524b1b5df217c20cd0431f6789851a4e0cb191b F tool/extract.c 054069d81b095fbdc189a6f5d4466e40380505e2 F tool/fast_vacuum.c 5ba0d6f5963a0a63bdc42840f678bad75b2ebce1 F tool/fragck.tcl 5265a95126abcf6ab357f7efa544787e5963f439 -F tool/fuzzershell.c e35a3e0918349f2a9e0498c17c6fe5a6c7d61d86 +F tool/fuzzershell.c 0b49a78e93feee0596f692c766cdff14186ae36c F tool/genfkey.README cf68fddd4643bbe3ff8e31b8b6d8b0a1b85e20f4 F tool/genfkey.test 4196a8928b78f51d54ef58e99e99401ab2f0a7e5 F tool/getlock.c f4c39b651370156cae979501a7b156bdba50e7ce @@ -1278,7 +1278,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 10cc44f5a63e6cadf6940bb7310a177ee7fa6ee2 -R 12583c8a4670388a5d60502757678b98 +P 89f0bbfde4d86a7b15e93aab9c487b4355c6fb2d +R 65016f3b238dc9d4aaf76f46b4ac610e U drh -Z f1e1ea5567a0f5557363801842b88558 +Z 79f3d7dfd072e74dd2fd5db7858a213f diff --git a/manifest.uuid b/manifest.uuid index 850b0dbfaf..3a72298708 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -89f0bbfde4d86a7b15e93aab9c487b4355c6fb2d \ No newline at end of file +745deab87adc378a5376aaa9451fb9485bc2f4c4 \ No newline at end of file diff --git a/tool/fuzzershell.c b/tool/fuzzershell.c index 6890c0be1e..c026cf370d 100644 --- a/tool/fuzzershell.c +++ b/tool/fuzzershell.c @@ -454,7 +454,7 @@ int main(int argc, char **argv){ int jj; /* Loop counter for azInFile[] */ sqlite3_int64 iBegin; /* Start time for the whole program */ sqlite3_int64 iStart, iEnd; /* Start and end-times for a test case */ - const char *zDbName; /* Name of an on-disk database file to open */ + const char *zDbName = 0; /* Name of an on-disk database file to open */ iBegin = timeOfDay(); zFailCode = getenv("TEST_FAILURE"); From c19bc9b6b04bb9c3aa2ca3076dfdf7bbf1b40533 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 22 May 2015 23:50:19 +0000 Subject: [PATCH 3/3] Improved error messages in fuzzershell when unable to open the database. FossilOrigin-Name: c404fcace83613a50015f15097b7f28123c221c3 --- manifest | 12 ++++++------ manifest.uuid | 2 +- tool/fuzzershell.c | 9 ++++++--- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 4d0c1f61ad..ee169cdc43 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sbug\sin\sfuzzershell\scaused\sby\san\suninitialized\slocal\svariable. -D 2015-05-22T23:45:56.266 +C Improved\serror\smessages\sin\sfuzzershell\swhen\sunable\sto\sopen\sthe\sdatabase. +D 2015-05-22T23:50:19.667 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 0a6ae26396ec696221021780dffbb894ff3cead7 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -1230,7 +1230,7 @@ F tool/diffdb.c 7524b1b5df217c20cd0431f6789851a4e0cb191b F tool/extract.c 054069d81b095fbdc189a6f5d4466e40380505e2 F tool/fast_vacuum.c 5ba0d6f5963a0a63bdc42840f678bad75b2ebce1 F tool/fragck.tcl 5265a95126abcf6ab357f7efa544787e5963f439 -F tool/fuzzershell.c 0b49a78e93feee0596f692c766cdff14186ae36c +F tool/fuzzershell.c f2fc86dd22df654b28851b85019d3bd007361751 F tool/genfkey.README cf68fddd4643bbe3ff8e31b8b6d8b0a1b85e20f4 F tool/genfkey.test 4196a8928b78f51d54ef58e99e99401ab2f0a7e5 F tool/getlock.c f4c39b651370156cae979501a7b156bdba50e7ce @@ -1278,7 +1278,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 89f0bbfde4d86a7b15e93aab9c487b4355c6fb2d -R 65016f3b238dc9d4aaf76f46b4ac610e +P 745deab87adc378a5376aaa9451fb9485bc2f4c4 +R 7f1ec43795b4d42a65936d3bb7f0111c U drh -Z 79f3d7dfd072e74dd2fd5db7858a213f +Z e4cfba910ab91f4d7a3f152da8ecf0bd diff --git a/manifest.uuid b/manifest.uuid index 3a72298708..18711cc258 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -745deab87adc378a5376aaa9451fb9485bc2f4c4 \ No newline at end of file +c404fcace83613a50015f15097b7f28123c221c3 \ No newline at end of file diff --git a/tool/fuzzershell.c b/tool/fuzzershell.c index c026cf370d..2778c9d2f7 100644 --- a/tool/fuzzershell.c +++ b/tool/fuzzershell.c @@ -701,14 +701,17 @@ int main(int argc, char **argv){ do{ if( zDbName ){ rc = sqlite3_open_v2(zDbName, &db, SQLITE_OPEN_READWRITE, 0); + if( rc!=SQLITE_OK ){ + abendError("Cannot open database file %s", zDbName); + } }else{ rc = sqlite3_open_v2( "main.db", &db, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_MEMORY, 0); - } - if( rc!=SQLITE_OK ){ - abendError("Unable to open the in-memory database"); + if( rc!=SQLITE_OK ){ + abendError("Unable to open the in-memory database"); + } } if( pLook ){ rc = sqlite3_db_config(db, SQLITE_DBCONFIG_LOOKASIDE,pLook,szLook,nLook);