diff options
author | drh <drh@noemail.net> | 2017-03-17 22:50:16 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2017-03-17 22:50:16 +0000 |
commit | 1cb0266dcb290384be714fca64710ce3035fb096 (patch) | |
tree | 5539114baebbb27413f0a1c029c2f9d1155a537b /src | |
parent | f53524b4f72be7e7cf96fdec983000c9e4c5a85a (diff) | |
download | sqlite-1cb0266dcb290384be714fca64710ce3035fb096.tar.gz sqlite-1cb0266dcb290384be714fca64710ce3035fb096.zip |
Begin enforcing the SQLITE_LIMIT_VDBE_OP. The documentation warned that this
day might come.
FossilOrigin-Name: ef5914617088cbf89bfae88f63ea959a07f02dff387ddc2b43948ad99c6a97b8
Diffstat (limited to 'src')
-rw-r--r-- | src/sqlite.h.in | 8 | ||||
-rw-r--r-- | src/sqliteLimit.h | 2 | ||||
-rw-r--r-- | src/vdbeaux.c | 6 |
3 files changed, 12 insertions, 4 deletions
diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 076a01131..5dd4419f4 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -3424,9 +3424,10 @@ int sqlite3_limit(sqlite3*, int id, int newVal); ** ** [[SQLITE_LIMIT_VDBE_OP]] ^(<dt>SQLITE_LIMIT_VDBE_OP</dt> ** <dd>The maximum number of instructions in a virtual machine program -** used to implement an SQL statement. This limit is not currently -** enforced, though that might be added in some future release of -** SQLite.</dd>)^ +** used to implement an SQL statement. If [sqlite3_prepare_v2()] or +** the equivalent tries to allocate space for more than this many opcodes +** in a single prepared statement, an SQLITE_NOMEM error is returned. +** A value of 0 means "unlimited".</dd>)^ ** ** [[SQLITE_LIMIT_FUNCTION_ARG]] ^(<dt>SQLITE_LIMIT_FUNCTION_ARG</dt> ** <dd>The maximum number of arguments on a function.</dd>)^ @@ -3464,6 +3465,7 @@ int sqlite3_limit(sqlite3*, int id, int newVal); #define SQLITE_LIMIT_TRIGGER_DEPTH 10 #define SQLITE_LIMIT_WORKER_THREADS 11 + /* ** CAPI3REF: Compiling An SQL Statement ** KEYWORDS: {SQL statement compiler} diff --git a/src/sqliteLimit.h b/src/sqliteLimit.h index 0554e6158..28e7a41cc 100644 --- a/src/sqliteLimit.h +++ b/src/sqliteLimit.h @@ -87,7 +87,7 @@ ** Not currently enforced. */ #ifndef SQLITE_MAX_VDBE_OP -# define SQLITE_MAX_VDBE_OP 25000 +# define SQLITE_MAX_VDBE_OP 250000000 #endif /* diff --git a/src/vdbeaux.c b/src/vdbeaux.c index ab4aad7a0..a8f215420 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -117,6 +117,12 @@ static int growOpArray(Vdbe *v, int nOp){ UNUSED_PARAMETER(nOp); #endif + /* Ensure that the size of a VDBE does not grow too large */ + if( nNew > p->db->aLimit[SQLITE_LIMIT_VDBE_OP] ){ + sqlite3OomFault(p->db); + return SQLITE_NOMEM; + } + assert( nOp<=(1024/sizeof(Op)) ); assert( nNew>=(p->nOpAlloc+nOp) ); pNew = sqlite3DbRealloc(p->db, v->aOp, nNew*sizeof(Op)); |