diff options
author | stephan <stephan@noemail.net> | 2023-10-13 12:48:35 +0000 |
---|---|---|
committer | stephan <stephan@noemail.net> | 2023-10-13 12:48:35 +0000 |
commit | 7dc0cc45f30a310dba12dcd3aaa554a146a5bf8e (patch) | |
tree | 0b4f7ed76a2f203012cdfd33965795efc25902c8 /src/loadext.c | |
parent | 99d43979d37b1aad05407f8b5523cfd44d9e64f3 (diff) | |
download | sqlite-7dc0cc45f30a310dba12dcd3aaa554a146a5bf8e.tar.gz sqlite-7dc0cc45f30a310dba12dcd3aaa554a146a5bf8e.zip |
Round one of an audit for SQLITE_ENABLE_API_ARMOR for functions exposed by JNI and those functions missing armor, as [forum:5e3fc453a69b49ca|reported in several forum posts].
FossilOrigin-Name: 8c25c4b18ad07861bf0e47f99f3db04b569b9b859ad0690602f748ddf3576939
Diffstat (limited to 'src/loadext.c')
-rw-r--r-- | src/loadext.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/loadext.c b/src/loadext.c index e792fa5a9..cfa8ba4ca 100644 --- a/src/loadext.c +++ b/src/loadext.c @@ -730,6 +730,9 @@ void sqlite3CloseExtensions(sqlite3 *db){ ** default so as not to open security holes in older applications. */ int sqlite3_enable_load_extension(sqlite3 *db, int onoff){ +#ifdef SQLITE_ENABLE_API_ARMOR + if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT; +#endif sqlite3_mutex_enter(db->mutex); if( onoff ){ db->flags |= SQLITE_LoadExtension|SQLITE_LoadExtFunc; @@ -751,7 +754,7 @@ int sqlite3_enable_load_extension(sqlite3 *db, int onoff){ */ typedef struct sqlite3AutoExtList sqlite3AutoExtList; static SQLITE_WSD struct sqlite3AutoExtList { - u32 nExt; /* Number of entries in aExt[] */ + u32 nExt; /* Number of entries in aExt[] */ void (**aExt)(void); /* Pointers to the extension init functions */ } sqlite3Autoext = { 0, 0 }; @@ -779,6 +782,9 @@ int sqlite3_auto_extension( void (*xInit)(void) ){ int rc = SQLITE_OK; +#ifdef SQLITE_ENABLE_API_ARMOR + if( xInit==0 ) return SQLITE_MISUSE_BKPT; +#endif #ifndef SQLITE_OMIT_AUTOINIT rc = sqlite3_initialize(); if( rc ){ @@ -831,6 +837,9 @@ int sqlite3_cancel_auto_extension( int i; int n = 0; wsdAutoextInit; +#ifdef SQLITE_ENABLE_API_ARMOR + if( xInit==0 ) return 0; +#endif sqlite3_mutex_enter(mutex); for(i=(int)wsdAutoext.nExt-1; i>=0; i--){ if( wsdAutoext.aExt[i]==xInit ){ |