Add API_ARMOR support to the sqlite3_result_...() family of functions and sqlite3_bind_zeroblob64().
FossilOrigin-Name: afabe3e35a66625527e2881749cdb6e13300888ab57bc0f05889d0e3ee203d73
This commit is contained in:
parent
7a54b12695
commit
c76e450908
12
manifest
12
manifest
@ -1,5 +1,5 @@
|
||||
C More\sAPI_ARMOR\sadditions.
|
||||
D 2023-10-14T14:53:18.394
|
||||
C Add\sAPI_ARMOR\ssupport\sto\sthe\ssqlite3_result_...()\sfamily\sof\sfunctions\sand\ssqlite3_bind_zeroblob64().
|
||||
D 2023-10-14T16:29:36.931
|
||||
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
||||
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
||||
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
|
||||
@ -787,7 +787,7 @@ F src/vacuum.c 604fcdaebe76f3497c855afcbf91b8fa5046b32de3045bab89cc008d68e40104
|
||||
F src/vdbe.c cd112eb00d20fc5cc44f631d0e713838602637328b0f127c2f3c2aa8cea3cc91
|
||||
F src/vdbe.h 41485521f68e9437fdb7ec4a90f9d86ab294e9bb8281e33b235915e29122cfc0
|
||||
F src/vdbeInt.h 949669dfd8a41550d27dcb905b494f2ccde9a2e6c1b0b04daa1227e2e74c2b2c
|
||||
F src/vdbeapi.c dbada91cc9f2e0b76ad4c76aad7b92fbe80c4a439b5dd8d7fa990d4e34b9831c
|
||||
F src/vdbeapi.c 0204e7247582975797a4b45606b39395c8a4f678d7c2b8dc15129044dcbb508f
|
||||
F src/vdbeaux.c 5b415e09b5b9d5be6c0f4fcbf18ea9d7d16f6a29ced2f14a3b2041020f63e9c1
|
||||
F src/vdbeblob.c 13f9287b55b6356b4b1845410382d6bede203ceb29ef69388a4a3d007ffacbe5
|
||||
F src/vdbemem.c 317b9f48708139db6239ade40c7980b4bc8233168383690d588dad6d8437f722
|
||||
@ -2128,8 +2128,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
|
||||
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
||||
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
||||
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
||||
P 0114a6622afc4588c47e98d804340449417b603dc4831513eab4d8e4ccb15d42
|
||||
R 376130abd753bb410df401995b876336
|
||||
P 78ebf838f645742f87733665cd72af736df345683b27377a2c8310c893b1769d
|
||||
R 71ff5d4a376fdfcdde5b2514a89cbed8
|
||||
U stephan
|
||||
Z fbd9ca46d7a725fcd4bdd4a5ef9f230a
|
||||
Z 2c334c3835eed2b31940cc452708383c
|
||||
# Remove this line to create a well-formed Fossil manifest.
|
||||
|
@ -1 +1 @@
|
||||
78ebf838f645742f87733665cd72af736df345683b27377a2c8310c893b1769d
|
||||
afabe3e35a66625527e2881749cdb6e13300888ab57bc0f05889d0e3ee203d73
|
@ -405,7 +405,7 @@ static void setResultStrOrError(
|
||||
static int invokeValueDestructor(
|
||||
const void *p, /* Value to destroy */
|
||||
void (*xDel)(void*), /* The destructor */
|
||||
sqlite3_context *pCtx /* Set a SQLITE_TOOBIG error if no NULL */
|
||||
sqlite3_context *pCtx /* Set a SQLITE_TOOBIG error if not NULL */
|
||||
){
|
||||
assert( xDel!=SQLITE_DYNAMIC );
|
||||
if( xDel==0 ){
|
||||
@ -415,7 +415,9 @@ static int invokeValueDestructor(
|
||||
}else{
|
||||
xDel((void*)p);
|
||||
}
|
||||
sqlite3_result_error_toobig(pCtx);
|
||||
if( pCtx!=0 ){
|
||||
sqlite3_result_error_toobig(pCtx);
|
||||
}
|
||||
return SQLITE_TOOBIG;
|
||||
}
|
||||
void sqlite3_result_blob(
|
||||
@ -424,6 +426,12 @@ void sqlite3_result_blob(
|
||||
int n,
|
||||
void (*xDel)(void *)
|
||||
){
|
||||
#ifdef SQLITE_ENABLE_API_ARMOR
|
||||
if( pCtx==0 || n<0 ){
|
||||
invokeValueDestructor(z, xDel, pCtx);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
assert( n>=0 );
|
||||
assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
|
||||
setResultStrOrError(pCtx, z, n, 0, xDel);
|
||||
@ -434,8 +442,14 @@ void sqlite3_result_blob64(
|
||||
sqlite3_uint64 n,
|
||||
void (*xDel)(void *)
|
||||
){
|
||||
assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
|
||||
assert( xDel!=SQLITE_DYNAMIC );
|
||||
#ifdef SQLITE_ENABLE_API_ARMOR
|
||||
if( pCtx==0 ){
|
||||
invokeValueDestructor(z, xDel, 0);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
|
||||
if( n>0x7fffffff ){
|
||||
(void)invokeValueDestructor(z, xDel, pCtx);
|
||||
}else{
|
||||
@ -443,30 +457,48 @@ void sqlite3_result_blob64(
|
||||
}
|
||||
}
|
||||
void sqlite3_result_double(sqlite3_context *pCtx, double rVal){
|
||||
#ifdef SQLITE_ENABLE_API_ARMOR
|
||||
if( pCtx==0 ) return;
|
||||
#endif
|
||||
assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
|
||||
sqlite3VdbeMemSetDouble(pCtx->pOut, rVal);
|
||||
}
|
||||
void sqlite3_result_error(sqlite3_context *pCtx, const char *z, int n){
|
||||
#ifdef SQLITE_ENABLE_API_ARMOR
|
||||
if( pCtx==0 ) return;
|
||||
#endif
|
||||
assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
|
||||
pCtx->isError = SQLITE_ERROR;
|
||||
sqlite3VdbeMemSetStr(pCtx->pOut, z, n, SQLITE_UTF8, SQLITE_TRANSIENT);
|
||||
}
|
||||
#ifndef SQLITE_OMIT_UTF16
|
||||
void sqlite3_result_error16(sqlite3_context *pCtx, const void *z, int n){
|
||||
#ifdef SQLITE_ENABLE_API_ARMOR
|
||||
if( pCtx==0 ) return;
|
||||
#endif
|
||||
assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
|
||||
pCtx->isError = SQLITE_ERROR;
|
||||
sqlite3VdbeMemSetStr(pCtx->pOut, z, n, SQLITE_UTF16NATIVE, SQLITE_TRANSIENT);
|
||||
}
|
||||
#endif
|
||||
void sqlite3_result_int(sqlite3_context *pCtx, int iVal){
|
||||
#ifdef SQLITE_ENABLE_API_ARMOR
|
||||
if( pCtx==0 ) return;
|
||||
#endif
|
||||
assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
|
||||
sqlite3VdbeMemSetInt64(pCtx->pOut, (i64)iVal);
|
||||
}
|
||||
void sqlite3_result_int64(sqlite3_context *pCtx, i64 iVal){
|
||||
#ifdef SQLITE_ENABLE_API_ARMOR
|
||||
if( pCtx==0 ) return;
|
||||
#endif
|
||||
assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
|
||||
sqlite3VdbeMemSetInt64(pCtx->pOut, iVal);
|
||||
}
|
||||
void sqlite3_result_null(sqlite3_context *pCtx){
|
||||
#ifdef SQLITE_ENABLE_API_ARMOR
|
||||
if( pCtx==0 ) return;
|
||||
#endif
|
||||
assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
|
||||
sqlite3VdbeMemSetNull(pCtx->pOut);
|
||||
}
|
||||
@ -476,14 +508,25 @@ void sqlite3_result_pointer(
|
||||
const char *zPType,
|
||||
void (*xDestructor)(void*)
|
||||
){
|
||||
Mem *pOut = pCtx->pOut;
|
||||
Mem *pOut;
|
||||
#ifdef SQLITE_ENABLE_API_ARMOR
|
||||
if( pCtx==0 ){
|
||||
invokeValueDestructor(pPtr, xDestructor, 0);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
pOut = pCtx->pOut;
|
||||
assert( sqlite3_mutex_held(pOut->db->mutex) );
|
||||
sqlite3VdbeMemRelease(pOut);
|
||||
pOut->flags = MEM_Null;
|
||||
sqlite3VdbeMemSetPointer(pOut, pPtr, zPType, xDestructor);
|
||||
}
|
||||
void sqlite3_result_subtype(sqlite3_context *pCtx, unsigned int eSubtype){
|
||||
Mem *pOut = pCtx->pOut;
|
||||
Mem *pOut;
|
||||
#ifdef SQLITE_ENABLE_API_ARMOR
|
||||
if( pCtx==0 ) return;
|
||||
#endif
|
||||
pOut = pCtx->pOut;
|
||||
assert( sqlite3_mutex_held(pOut->db->mutex) );
|
||||
pOut->eSubtype = eSubtype & 0xff;
|
||||
pOut->flags |= MEM_Subtype;
|
||||
@ -494,6 +537,12 @@ void sqlite3_result_text(
|
||||
int n,
|
||||
void (*xDel)(void *)
|
||||
){
|
||||
#ifdef SQLITE_ENABLE_API_ARMOR
|
||||
if( pCtx==0 ){
|
||||
invokeValueDestructor(z, xDel, 0);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
|
||||
setResultStrOrError(pCtx, z, n, SQLITE_UTF8, xDel);
|
||||
}
|
||||
@ -504,6 +553,12 @@ void sqlite3_result_text64(
|
||||
void (*xDel)(void *),
|
||||
unsigned char enc
|
||||
){
|
||||
#ifdef SQLITE_ENABLE_API_ARMOR
|
||||
if( pCtx==0 ){
|
||||
invokeValueDestructor(z, xDel, 0);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
|
||||
assert( xDel!=SQLITE_DYNAMIC );
|
||||
if( enc!=SQLITE_UTF8 ){
|
||||
@ -568,7 +623,12 @@ void sqlite3_result_zeroblob(sqlite3_context *pCtx, int n){
|
||||
sqlite3_result_zeroblob64(pCtx, n>0 ? n : 0);
|
||||
}
|
||||
int sqlite3_result_zeroblob64(sqlite3_context *pCtx, u64 n){
|
||||
Mem *pOut = pCtx->pOut;
|
||||
Mem *pOut;
|
||||
|
||||
#ifdef SQLITE_ENABLE_API_ARMOR
|
||||
if( pCtx==0 ) return SQLITE_MISUSE_BKPT;
|
||||
#endif
|
||||
pOut = pCtx->pOut;
|
||||
assert( sqlite3_mutex_held(pOut->db->mutex) );
|
||||
if( n>(u64)pOut->db->aLimit[SQLITE_LIMIT_LENGTH] ){
|
||||
sqlite3_result_error_toobig(pCtx);
|
||||
@ -582,6 +642,9 @@ int sqlite3_result_zeroblob64(sqlite3_context *pCtx, u64 n){
|
||||
#endif
|
||||
}
|
||||
void sqlite3_result_error_code(sqlite3_context *pCtx, int errCode){
|
||||
#ifdef SQLITE_ENABLE_API_ARMOR
|
||||
if( pCtx==0 ) return;
|
||||
#endif
|
||||
pCtx->isError = errCode ? errCode : -1;
|
||||
#ifdef SQLITE_DEBUG
|
||||
if( pCtx->pVdbe ) pCtx->pVdbe->rcApp = errCode;
|
||||
@ -594,6 +657,9 @@ void sqlite3_result_error_code(sqlite3_context *pCtx, int errCode){
|
||||
|
||||
/* Force an SQLITE_TOOBIG error. */
|
||||
void sqlite3_result_error_toobig(sqlite3_context *pCtx){
|
||||
#ifdef SQLITE_ENABLE_API_ARMOR
|
||||
if( pCtx==0 ) return;
|
||||
#endif
|
||||
assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
|
||||
pCtx->isError = SQLITE_TOOBIG;
|
||||
sqlite3VdbeMemSetStr(pCtx->pOut, "string or blob too big", -1,
|
||||
@ -602,6 +668,9 @@ void sqlite3_result_error_toobig(sqlite3_context *pCtx){
|
||||
|
||||
/* An SQLITE_NOMEM error. */
|
||||
void sqlite3_result_error_nomem(sqlite3_context *pCtx){
|
||||
#ifdef SQLITE_ENABLE_API_ARMOR
|
||||
if( pCtx==0 ) return;
|
||||
#endif
|
||||
assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
|
||||
sqlite3VdbeMemSetNull(pCtx->pOut);
|
||||
pCtx->isError = SQLITE_NOMEM_BKPT;
|
||||
@ -1765,6 +1834,9 @@ int sqlite3_bind_zeroblob(sqlite3_stmt *pStmt, int i, int n){
|
||||
int sqlite3_bind_zeroblob64(sqlite3_stmt *pStmt, int i, sqlite3_uint64 n){
|
||||
int rc;
|
||||
Vdbe *p = (Vdbe *)pStmt;
|
||||
#ifdef SQLITE_ENABLE_API_ARMOR
|
||||
if( p==0 ) return SQLITE_MISUSE_BKPT;
|
||||
#endif
|
||||
sqlite3_mutex_enter(p->db->mutex);
|
||||
if( n>(u64)p->db->aLimit[SQLITE_LIMIT_LENGTH] ){
|
||||
rc = SQLITE_TOOBIG;
|
||||
|
Loading…
Reference in New Issue
Block a user