/ Check-in [4e1b005e8b]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:When deserializing a database (sqlite3_deserialize()), do not attempt to parse the schema before the data is loaded.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 4e1b005e8b397a22161a6b89cbd3f17bda70a6e0a86d8abdc61856edf2a74da4
User & Date: dan 2019-03-13 11:40:30
Context
2019-03-13
13:19
New test cases added to test/fuzzdata8.db check-in: 049e992620 user: drh tags: trunk
11:40
When deserializing a database (sqlite3_deserialize()), do not attempt to parse the schema before the data is loaded. check-in: 4e1b005e8b user: dan tags: trunk
10:29
Detect zero-length free slots on btree pages and report that as corruption. check-in: c4f0568fde user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/attach.c.

   230    230     ** remove the entry from the db->aDb[] array. i.e. put everything back the
   231    231     ** way we found it.
   232    232     */
   233    233     if( rc==SQLITE_OK ){
   234    234       sqlite3BtreeEnterAll(db);
   235    235       db->init.iDb = 0;
   236    236       db->mDbFlags &= ~(DBFLAG_SchemaKnownOk);
   237         -    rc = sqlite3Init(db, &zErrDyn);
          237  +    if( !REOPEN_AS_MEMDB(db) ){
          238  +      rc = sqlite3Init(db, &zErrDyn);
          239  +    }
   238    240       sqlite3BtreeLeaveAll(db);
   239    241       assert( zErrDyn==0 || rc!=SQLITE_OK );
   240    242     }
   241    243   #ifdef SQLITE_USER_AUTHENTICATION
   242    244     if( rc==SQLITE_OK ){
   243    245       u8 newAuth = 0;
   244    246       rc = sqlite3UserAuthCheckLogin(db, zName, &newAuth);

Changes to test/corruptL.test.

   119    119   |   2512: 00 00 00 00 00 00 00 00 aa 00 00 00 00 00 00 00   ................
   120    120   | end crash-acaae0347204ae.db
   121    121   }]} {}
   122    122   
   123    123   do_catchsql_test 1.1 {
   124    124     PRAGMA cell_size_check = off;
   125    125     DROP INDEX t1x1;
   126         -} {1 {no such index: t1x1}}
          126  +} {1 {database disk image is malformed}}
   127    127   
   128    128   do_catchsql_test 1.2 {
   129    129     SELECT sum(s+length(b)) FROM t1 WHERE a IN (110,10,150) AND q IS NULL;
   130         -} {1 {no such table: t1}}
          130  +} {1 {database disk image is malformed}}
   131    131   
   132    132   do_catchsql_test 1.3 {
   133    133     REINDEX t1;
   134         -} {1 {unable to identify the object to be reindexed}}
          134  +} {1 {database disk image is malformed}}
          135  +
          136  +do_catchsql_test 1.4 {
          137  +  PRAGMA integrity_check
          138  +} {1 {database disk image is malformed}}
          139  +
   135    140   
   136    141   #-------------------------------------------------------------------------
   137    142   reset_db
   138    143   do_test 2.0 {
   139    144     sqlite3 db {}
   140    145     db deserialize [decode_hexdb {
   141    146   | size 20480 pagesize 4096 filename crash.txt.db

Changes to test/memdb1.test.

   180    180     set rc [catch {db deserialize a b c} msg]
   181    181     lappend rc $msg
   182    182   } {1 {unknown option: a}}
   183    183   do_test 620 {
   184    184     set rc [catch {db serialize a b} msg]
   185    185     lappend rc $msg
   186    186   } {1 {wrong # args: should be "db serialize ?DATABASE?"}}
          187  +
          188  +#-------------------------------------------------------------------------
          189  +reset_db
          190  +do_execsql_test 700 {
          191  +  CREATE TABLE t1(a, b);
          192  +  PRAGMA schema_version = 0;
          193  +}
          194  +do_test 710 {
          195  +  set ser [db serialize main]
          196  +  db close
          197  +  sqlite3 db
          198  +  db deserialize main $ser
          199  +  catchsql {
          200  +    CREATE VIRTUAL TABLE t1 USING rtree(id, a, b, c, d);
          201  +  }
          202  +} {1 {table t1 already exists}}
   187    203   
   188    204   finish_test