@@ -32262,6 +32262,10 @@ SQLITE_PRIVATE const char *sqlite3OpcodeName(int i){
3226232262# include <sys/mount.h>
3226332263#endif
3226432264
32265+ #if defined(__BIONIC__) && __ANDROID_API__ >= __ANDROID_API_Q__
32266+ # include <android/fdsan.h>
32267+ #endif
32268+
3226532269#ifdef HAVE_UTIME
3226632270# include <utime.h>
3226732271#endif
@@ -33021,6 +33025,12 @@ static int robust_open(const char *z, int f, mode_t m){
3302133025#if defined(FD_CLOEXEC) && (!defined(O_CLOEXEC) || O_CLOEXEC==0)
3302233026 osFcntl(fd, F_SETFD, osFcntl(fd, F_GETFD, 0) | FD_CLOEXEC);
3302333027#endif
33028+
33029+ #if defined(__BIONIC__) && __ANDROID_API__ >= __ANDROID_API_Q__
33030+ uint64_t tag = android_fdsan_create_owner_tag(
33031+ ANDROID_FDSAN_OWNER_TYPE_SQLITE, fd);
33032+ android_fdsan_exchange_owner_tag(fd, 0, tag);
33033+ #endif
3302433034 }
3302533035 return fd;
3302633036}
@@ -33601,7 +33611,13 @@ static int unixLogErrorAtLine(
3360133611** and move on.
3360233612*/
3360333613static void robust_close(unixFile *pFile, int h, int lineno){
33614+ #if defined(__BIONIC__) && __ANDROID_API__ >= __ANDROID_API_Q__
33615+ uint64_t tag = android_fdsan_create_owner_tag(
33616+ ANDROID_FDSAN_OWNER_TYPE_SQLITE, h);
33617+ if( android_fdsan_close_with_tag(h, tag) ){
33618+ #else
3360433619 if( osClose(h) ){
33620+ #endif
3360533621 unixLogErrorAtLine(SQLITE_IOERR_CLOSE, "close",
3360633622 pFile ? pFile->zPath : 0, lineno);
3360733623 }
@@ -36134,7 +36150,7 @@ static int unixFileSize(sqlite3_file *id, i64 *pSize){
3613436150 SimulateIOError( rc=1 );
3613536151 if( rc!=0 ){
3613636152 storeLastErrno((unixFile*)id, errno);
36137- return SQLITE_IOERR_FSTAT;
36153+ return unixLogError( SQLITE_IOERR_FSTAT, "fstat", ((unixFile*)id)->zPath) ;
3613836154 }
3613936155 *pSize = buf.st_size;
3614036156
@@ -36170,7 +36186,7 @@ static int fcntlSizeHint(unixFile *pFile, i64 nByte){
3617036186 struct stat buf; /* Used to hold return values of fstat() */
3617136187
3617236188 if( osFstat(pFile->h, &buf) ){
36173- return SQLITE_IOERR_FSTAT;
36189+ return unixLogError( SQLITE_IOERR_FSTAT, "fstat", pFile->zPath) ;
3617436190 }
3617536191
3617636192 nSize = ((nByte+pFile->szChunk-1) / pFile->szChunk) * pFile->szChunk;
@@ -36856,7 +36872,7 @@ static int unixOpenSharedMemory(unixFile *pDbFd){
3685636872 ** with the same permissions.
3685736873 */
3685836874 if( osFstat(pDbFd->h, &sStat) ){
36859- rc = SQLITE_IOERR_FSTAT;
36875+ rc = unixLogError( SQLITE_IOERR_FSTAT, "fstat", pDbFd->zPath) ;
3686036876 goto shm_open_err;
3686136877 }
3686236878
@@ -122984,7 +123000,7 @@ SQLITE_PRIVATE int sqlite3InitOne(sqlite3 *db, int iDb, char **pzErrMsg, u32 mFl
122984123000 }
122985123001 if( pDb->pSchema->file_format>SQLITE_MAX_FILE_FORMAT ){
122986123002 sqlite3SetString(pzErrMsg, db, "unsupported file format");
122987- rc = SQLITE_ERROR;
123003+ rc = SQLITE_CORRUPT_BKPT; // Android Change from "rc = SQLITE_ERROR;" ;
122988123004 goto initone_error_out;
122989123005 }
122990123006
@@ -162306,13 +162322,25 @@ SQLITE_PRIVATE int sqlite3Fts3Init(sqlite3 *db){
162306162322 ** module with sqlite.
162307162323 */
162308162324 if( SQLITE_OK==rc
162325+ #ifndef ANDROID /* fts3_tokenizer disabled for security reasons */
162309162326 && SQLITE_OK==(rc = sqlite3Fts3InitHashTable(db, pHash, "fts3_tokenizer"))
162327+ #endif
162310162328 && SQLITE_OK==(rc = sqlite3_overload_function(db, "snippet", -1))
162311162329 && SQLITE_OK==(rc = sqlite3_overload_function(db, "offsets", 1))
162312162330 && SQLITE_OK==(rc = sqlite3_overload_function(db, "matchinfo", 1))
162313162331 && SQLITE_OK==(rc = sqlite3_overload_function(db, "matchinfo", 2))
162314162332 && SQLITE_OK==(rc = sqlite3_overload_function(db, "optimize", 1))
162315162333 ){
162334+ #ifdef SQLITE_ENABLE_FTS3_BACKWARDS
162335+ rc = sqlite3_create_module_v2(
162336+ db, "fts1", &fts3Module, (void *)pHash, 0
162337+ );
162338+ if(rc) return rc;
162339+ rc = sqlite3_create_module_v2(
162340+ db, "fts2", &fts3Module, (void *)pHash, 0
162341+ );
162342+ if(rc) return rc;
162343+ #endif
162316162344 rc = sqlite3_create_module_v2(
162317162345 db, "fts3", &fts3Module, (void *)pHash, hashDestroy
162318162346 );
0 commit comments