aboutsummaryrefslogtreecommitdiff
path: root/src/vdbeapi.c
diff options
context:
space:
mode:
authordrh <>2023-01-25 16:56:24 +0000
committerdrh <>2023-01-25 16:56:24 +0000
commitb604f1456e4116b6a60d0d24a0ed1e678617dcf3 (patch)
treea57d0215a3c6ba7fec7b10d4d90118af14307715 /src/vdbeapi.c
parenta0fe1e7d137334aaf7e6518165894bc5fe15dbe8 (diff)
downloadsqlite-b604f1456e4116b6a60d0d24a0ed1e678617dcf3.tar.gz
sqlite-b604f1456e4116b6a60d0d24a0ed1e678617dcf3.zip
Enhance the sqlite3_vtab_in_first() and sqlite3_vtab_in_next() interfaces so
that they reliably return SQLITE_ERROR (and not SQLITE_MISUSE) if they are invoked on a parameter that did not have multi-value IN processing enabled via a prior call to sqlite3_vtab_in(). See [forum:/forumpost/a823d4a3d5f73def|forum thread a823d4a3d5f73def]. FossilOrigin-Name: 144326dc171025dc8b5a77bebd8de3c19d5244ab807f5aa41f95313a25b880bc
Diffstat (limited to 'src/vdbeapi.c')
-rw-r--r--src/vdbeapi.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/vdbeapi.c b/src/vdbeapi.c
index e080449c5..647976b5f 100644
--- a/src/vdbeapi.c
+++ b/src/vdbeapi.c
@@ -883,6 +883,17 @@ int sqlite3_vtab_nochange(sqlite3_context *p){
}
/*
+** The destructor function for a ValueList object. This needs to be
+** a separate function, unknowable to the application, to ensure that
+** calls to sqlite3_vtab_in_first()/sqlite3_vtab_in_next() that are not
+** preceeded by activation of IN processing via sqlite3_vtab_int() do not
+** try to access a fake ValueList object inserted by a hostile extension.
+*/
+void sqlite3VdbeValueListFree(void *pToDelete){
+ sqlite3_free(pToDelete);
+}
+
+/*
** Implementation of sqlite3_vtab_in_first() (if bNext==0) and
** sqlite3_vtab_in_next() (if bNext!=0).
*/
@@ -896,8 +907,15 @@ static int valueFromValueList(
*ppOut = 0;
if( pVal==0 ) return SQLITE_MISUSE;
- pRhs = (ValueList*)sqlite3_value_pointer(pVal, "ValueList");
- if( pRhs==0 ) return SQLITE_MISUSE;
+ if( pVal->xDel!=sqlite3VdbeValueListFree ){
+ return SQLITE_ERROR;
+ }else{
+ assert( (pVal->flags&(MEM_TypeMask|MEM_Term|MEM_Subtype)) ==
+ (MEM_Null|MEM_Term|MEM_Subtype) );
+ assert( pVal->eSubtype=='p' );
+ assert( pVal->u.zPType!=0 && strcmp(pVal->u.zPType,"ValueList")==0 );
+ pRhs = (ValueList*)pVal->z;
+ }
if( bNext ){
rc = sqlite3BtreeNext(pRhs->pCsr, 0);
}else{