diff options
author | mistachkin <mistachkin@noemail.net> | 2014-12-20 21:14:14 +0000 |
---|---|---|
committer | mistachkin <mistachkin@noemail.net> | 2014-12-20 21:14:14 +0000 |
commit | cd54bab6fe5946c641979abfe7e16c42cf9436f1 (patch) | |
tree | 2cfe345bd90dd357fa3bbd49cea81c2d5d6636df /src | |
parent | 59871fe748429e26822293826b27017a7dae2ff7 (diff) | |
download | sqlite-cd54bab6fe5946c641979abfe7e16c42cf9436f1.tar.gz sqlite-cd54bab6fe5946c641979abfe7e16c42cf9436f1.zip |
Minor fixes and enhancements to the SQLITE_ENABLE_API_ARMOR functionality.
FossilOrigin-Name: cb3e4219ac9560d2773b85453aafda54b7c9346f
Diffstat (limited to 'src')
-rw-r--r-- | src/complete.c | 14 | ||||
-rw-r--r-- | src/main.c | 6 | ||||
-rw-r--r-- | src/mutex_w32.c | 6 | ||||
-rw-r--r-- | src/table.c | 2 | ||||
-rw-r--r-- | src/tokenize.c | 3 |
5 files changed, 21 insertions, 10 deletions
diff --git a/src/complete.c b/src/complete.c index c439cfe18..f7a35cc6f 100644 --- a/src/complete.c +++ b/src/complete.c @@ -105,13 +105,6 @@ int sqlite3_complete(const char *zSql){ u8 state = 0; /* Current state, using numbers defined in header comment */ u8 token; /* Value of the next token */ -#ifdef SQLITE_ENABLE_API_ARMOR - if( zSql==0 ){ - (void)SQLITE_MISUSE_BKPT; - return 0; - } -#endif - #ifndef SQLITE_OMIT_TRIGGER /* A complex statement machine used to detect the end of a CREATE TRIGGER ** statement. This is the normal case. @@ -141,6 +134,13 @@ int sqlite3_complete(const char *zSql){ }; #endif /* SQLITE_OMIT_TRIGGER */ +#ifdef SQLITE_ENABLE_API_ARMOR + if( zSql==0 ){ + (void)SQLITE_MISUSE_BKPT; + return 0; + } +#endif + while( *zSql ){ switch( *zSql ){ case ';': { /* A semicolon */ diff --git a/src/main.c b/src/main.c index c89ccbd55..76af9a2e9 100644 --- a/src/main.c +++ b/src/main.c @@ -3659,13 +3659,14 @@ Btree *sqlite3DbNameToBtree(sqlite3 *db, const char *zDbName){ ** connection. */ const char *sqlite3_db_filename(sqlite3 *db, const char *zDbName){ + Btree *pBt; #ifdef SQLITE_ENABLE_API_ARMOR if( !sqlite3SafetyCheckOk(db) ){ (void)SQLITE_MISUSE_BKPT; return 0; } #endif - Btree *pBt = sqlite3DbNameToBtree(db, zDbName); + pBt = sqlite3DbNameToBtree(db, zDbName); return pBt ? sqlite3BtreeGetFilename(pBt) : 0; } @@ -3674,12 +3675,13 @@ const char *sqlite3_db_filename(sqlite3 *db, const char *zDbName){ ** no such database exists. */ int sqlite3_db_readonly(sqlite3 *db, const char *zDbName){ + Btree *pBt; #ifdef SQLITE_ENABLE_API_ARMOR if( !sqlite3SafetyCheckOk(db) ){ (void)SQLITE_MISUSE_BKPT; return -1; } #endif - Btree *pBt = sqlite3DbNameToBtree(db, zDbName); + pBt = sqlite3DbNameToBtree(db, zDbName); return pBt ? sqlite3BtreeIsReadonly(pBt) : -1; } diff --git a/src/mutex_w32.c b/src/mutex_w32.c index da7d73f7c..a799c8615 100644 --- a/src/mutex_w32.c +++ b/src/mutex_w32.c @@ -209,6 +209,12 @@ static sqlite3_mutex *winMutexAlloc(int iType){ break; } default: { +#ifdef SQLITE_ENABLE_API_ARMOR + if( iType-2<0 || iType-2>=ArraySize(winMutex_staticMutexes) ){ + (void)SQLITE_MISUSE_BKPT; + return 0; + } +#endif assert( iType-2 >= 0 ); assert( iType-2 < ArraySize(winMutex_staticMutexes) ); assert( winMutex_isInit==1 ); diff --git a/src/table.c b/src/table.c index 6e1df3064..235d8dd3d 100644 --- a/src/table.c +++ b/src/table.c @@ -127,7 +127,7 @@ int sqlite3_get_table( TabResult res; #ifdef SQLITE_ENABLE_API_ARMOR - if( pazResult==0 ) return SQLITE_MISUSE_BKPT; + if( !sqlite3SafetyCheckOk(db) || pazResult==0 ) return SQLITE_MISUSE_BKPT; #endif *pazResult = 0; if( pnColumn ) *pnColumn = 0; diff --git a/src/tokenize.c b/src/tokenize.c index 5bb915546..f0360eef6 100644 --- a/src/tokenize.c +++ b/src/tokenize.c @@ -391,6 +391,9 @@ int sqlite3RunParser(Parse *pParse, const char *zSql, char **pzErrMsg){ int mxSqlLen; /* Max length of an SQL string */ +#ifdef SQLITE_ENABLE_API_ARMOR + if( zSql==0 || pzErrMsg==0 ) return SQLITE_MISUSE_BKPT; +#endif mxSqlLen = db->aLimit[SQLITE_LIMIT_SQL_LENGTH]; if( db->nVdbeActive==0 ){ db->u1.isInterrupted = 0; |