aboutsummaryrefslogtreecommitdiff
path: root/src/memdb.c
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2019-01-25 14:16:01 +0000
committerdrh <drh@noemail.net>2019-01-25 14:16:01 +0000
commit94f0a8342106b4e1af85bf658bdf1c12ed010c73 (patch)
tree099f6026c33d50f3f6636b33bc587889a0cefd4e /src/memdb.c
parent725a9c7f6c0d406cac38d41d286c023dd5896417 (diff)
downloadsqlite-94f0a8342106b4e1af85bf658bdf1c12ed010c73.tar.gz
sqlite-94f0a8342106b4e1af85bf658bdf1c12ed010c73.zip
Fix the xFetch method of the "memdb" VFS (used by deserialize) so that it
is robust against corrupt database file. FossilOrigin-Name: 2c1ef40e787a6bc355b50168527a47eb09acd30d0d88cff8336a434ad554115d
Diffstat (limited to 'src/memdb.c')
-rw-r--r--src/memdb.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/memdb.c b/src/memdb.c
index e7366961f..75e83a95d 100644
--- a/src/memdb.c
+++ b/src/memdb.c
@@ -310,8 +310,13 @@ static int memdbFetch(
void **pp
){
MemFile *p = (MemFile *)pFile;
- p->nMmap++;
- *pp = (void*)(p->aData + iOfst);
+ if( iOfst+iAmt>p->sz ){
+ assert( CORRUPT_DB );
+ *pp = 0;
+ }else{
+ p->nMmap++;
+ *pp = (void*)(p->aData + iOfst);
+ }
return SQLITE_OK;
}