SQLite

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
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 4e1b005e8b397a22161a6b89cbd3f17bda70a6e0a86d8abdc61856edf2a74da4
User & Date: dan 2019-03-13 11:40:30.869
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
Side-by-Side Diff Ignore Whitespace Patch
Changes to src/attach.c.
230
231
232
233
234
235
236

237


238
239
240
241
242
243
244
230
231
232
233
234
235
236
237

238
239
240
241
242
243
244
245
246







+
-
+
+







  ** remove the entry from the db->aDb[] array. i.e. put everything back the
  ** way we found it.
  */
  if( rc==SQLITE_OK ){
    sqlite3BtreeEnterAll(db);
    db->init.iDb = 0;
    db->mDbFlags &= ~(DBFLAG_SchemaKnownOk);
    if( !REOPEN_AS_MEMDB(db) ){
    rc = sqlite3Init(db, &zErrDyn);
      rc = sqlite3Init(db, &zErrDyn);
    }
    sqlite3BtreeLeaveAll(db);
    assert( zErrDyn==0 || rc!=SQLITE_OK );
  }
#ifdef SQLITE_USER_AUTHENTICATION
  if( rc==SQLITE_OK ){
    u8 newAuth = 0;
    rc = sqlite3UserAuthCheckLogin(db, zName, &newAuth);
Changes to test/corruptL.test.
119
120
121
122
123
124
125
126

127
128
129
130

131
132
133

134





135
136
137
138
139
140
141
119
120
121
122
123
124
125

126
127
128
129

130
131
132
133
134

135
136
137
138
139
140
141
142
143
144
145
146







-
+



-
+



+
-
+
+
+
+
+







|   2512: 00 00 00 00 00 00 00 00 aa 00 00 00 00 00 00 00   ................
| end crash-acaae0347204ae.db
}]} {}

do_catchsql_test 1.1 {
  PRAGMA cell_size_check = off;
  DROP INDEX t1x1;
} {1 {no such index: t1x1}}
} {1 {database disk image is malformed}}

do_catchsql_test 1.2 {
  SELECT sum(s+length(b)) FROM t1 WHERE a IN (110,10,150) AND q IS NULL;
} {1 {no such table: t1}}
} {1 {database disk image is malformed}}

do_catchsql_test 1.3 {
  REINDEX t1;
} {1 {database disk image is malformed}}
} {1 {unable to identify the object to be reindexed}}

do_catchsql_test 1.4 {
  PRAGMA integrity_check
} {1 {database disk image is malformed}}


#-------------------------------------------------------------------------
reset_db
do_test 2.0 {
  sqlite3 db {}
  db deserialize [decode_hexdb {
| size 20480 pagesize 4096 filename crash.txt.db
Changes to test/memdb1.test.
180
181
182
183
184
185
186
















187
188
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204







+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+


  set rc [catch {db deserialize a b c} msg]
  lappend rc $msg
} {1 {unknown option: a}}
do_test 620 {
  set rc [catch {db serialize a b} msg]
  lappend rc $msg
} {1 {wrong # args: should be "db serialize ?DATABASE?"}}

#-------------------------------------------------------------------------
reset_db
do_execsql_test 700 {
  CREATE TABLE t1(a, b);
  PRAGMA schema_version = 0;
}
do_test 710 {
  set ser [db serialize main]
  db close
  sqlite3 db
  db deserialize main $ser
  catchsql {
    CREATE VIRTUAL TABLE t1 USING rtree(id, a, b, c, d);
  }
} {1 {table t1 already exists}}

finish_test