Skip to content

Commit 575637d

Browse files
committed
Add version schema check.
1 parent 0c2a8cc commit 575637d

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

ceshim.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,11 @@ static int ceshimPagerLock(ceshim_file *p){
491491
}else{
492492
// restore some data
493493
rc = ceshimLoadHeader(p);
494+
if( rc==SQLITE_OK && pInfo->ceshimHeader.schema > CESHIM_FILE_SCHEMA_NO ){
495+
// The file schema# is larger than this version can handle.
496+
// A newer version is needed to read this file.
497+
rc = CESHIM_ERROR_EXT_VERSION_TOO_OLD;
498+
}
494499
if( rc==SQLITE_OK ) rc = ceshimLoadMMTbl(p);
495500
if( rc==SQLITE_OK ) rc = ceshimLoadPagemapData(p, 0);
496501
}

ceshim.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@
99
#ifndef ceshim_h
1010
#define ceshim_h
1111

12-
#define CESHIM_ERROR 400
12+
#define CESHIM_ERROR 111
1313
#define CESHIM_ERROR_PAGE_SIZE_TOO_SMALL (CESHIM_ERROR | (1<<8))
1414
#define CESHIM_ERROR_MALFORMED_KEY (CESHIM_ERROR | (2<<8))
15+
#define CESHIM_ERROR_EXT_VERSION_TOO_OLD (CESHIM_ERROR | (3<<8))
1516

1617
int ceshim_register(
1718
const char *zName, /* Name of the newly constructed VFS */

0 commit comments

Comments
 (0)