diff options
author | drh <> | 2022-09-02 11:12:16 +0000 |
---|---|---|
committer | drh <> | 2022-09-02 11:12:16 +0000 |
commit | fee6431392efdbf83d4efdbd639f1f37f4ebb275 (patch) | |
tree | b19b754f6d8107e85b8987a4505a39b9813d808e /src | |
parent | 18a3a48db1ff3f4fef94915e2021c5d0a790d24b (diff) | |
download | sqlite-fee6431392efdbf83d4efdbd639f1f37f4ebb275.tar.gz sqlite-fee6431392efdbf83d4efdbd639f1f37f4ebb275.zip |
Improved mutex protection of the sqlite3_temp_directory and
sqlite3_data_directory global variables.
FossilOrigin-Name: ebbe9634d6dde9e097f61fb98a79111e46de422b7bbbd9ed3af7b6f22aacf5ec
Diffstat (limited to 'src')
-rw-r--r-- | src/os_win.c | 21 | ||||
-rw-r--r-- | src/sqliteInt.h | 3 |
2 files changed, 16 insertions, 8 deletions
diff --git a/src/os_win.c b/src/os_win.c index 591f57ee5..4191db6bb 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -5576,7 +5576,7 @@ static BOOL winIsVerbatimPathname( ** pathname into zOut[]. zOut[] will be at least pVfs->mxPathname ** bytes in size. */ -static int winFullPathname( +static int winFullPathnameNoMutex( sqlite3_vfs *pVfs, /* Pointer to vfs object */ const char *zRelative, /* Possibly relative input path */ int nFull, /* Size of output buffer in bytes */ @@ -5600,7 +5600,6 @@ static int winFullPathname( SimulateIOError( return SQLITE_ERROR ); UNUSED_PARAMETER(nFull); assert( nFull>=pVfs->mxPathname ); - sqlite3_mutex_enter(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_TEMPDIR)); if ( sqlite3_data_directory && !winIsVerbatimPathname(zRelative) ){ /* ** NOTE: We are dealing with a relative path name and the data @@ -5651,7 +5650,6 @@ static int winFullPathname( sqlite3_free(zOut); } } - sqlite3_mutex_leave(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_TEMPDIR)); return SQLITE_OK; #endif @@ -5659,7 +5657,6 @@ static int winFullPathname( SimulateIOError( return SQLITE_ERROR ); /* WinCE has no concept of a relative pathname, or so I am told. */ /* WinRT has no way to convert a relative path to an absolute one. */ - sqlite3_mutex_enter(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_TEMPDIR)); if ( sqlite3_data_directory && !winIsVerbatimPathname(zRelative) ){ /* ** NOTE: We are dealing with a relative path name and the data @@ -5672,7 +5669,6 @@ static int winFullPathname( }else{ sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s", zRelative); } - sqlite3_mutex_leave(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_TEMPDIR)); return SQLITE_OK; #endif @@ -5683,7 +5679,6 @@ static int winFullPathname( ** current working directory has been unlinked. */ SimulateIOError( return SQLITE_ERROR ); - sqlite3_mutex_enter(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_TEMPDIR)); if ( sqlite3_data_directory && !winIsVerbatimPathname(zRelative) ){ /* ** NOTE: We are dealing with a relative path name and the data @@ -5693,7 +5688,6 @@ static int winFullPathname( */ sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s%c%s", sqlite3_data_directory, winGetDirSep(), zRelative); - sqlite3_mutex_leave(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_TEMPDIR)); return SQLITE_OK; } zConverted = winConvertFromUtf8Filename(zRelative); @@ -5761,6 +5755,19 @@ static int winFullPathname( } #endif } +static int winFullPathname( + sqlite3_vfs *pVfs, /* Pointer to vfs object */ + const char *zRelative, /* Possibly relative input path */ + int nFull, /* Size of output buffer in bytes */ + char *zFull /* Output buffer */ +){ + int rc; + sqlite3_mutex *pMutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_TEMPDIR); + sqlite3_mutex_enter(pMutex); + rc = winFullPathnameNoMutex(pVfs, zRelative, nFull, zFull); + sqlite3_mutex_leave(pMutex); + return rc; +} #ifndef SQLITE_OMIT_LOAD_EXTENSION /* diff --git a/src/sqliteInt.h b/src/sqliteInt.h index eef09e1f0..aeb4cac43 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -201,7 +201,7 @@ /* ** Reuse the STATIC_LRU for mutex access to sqlite3_temp_directory. */ -#define SQLITE_MUTEX_STATIC_TEMPDIR SQLITE_MUTEX_STATIC_LRU +#define SQLITE_MUTEX_STATIC_TEMPDIR SQLITE_MUTEX_STATIC_VFS1 /* ** Include the configuration header output by 'configure' if we're using the @@ -4561,6 +4561,7 @@ int sqlite3IndexHasDuplicateRootPage(Index*); int sqlite3Init(sqlite3*, char**); int sqlite3InitCallback(void*, int, char**, char**); int sqlite3InitOne(sqlite3*, int, char**, u32); +char *sqlite3TempDirectory(void); void sqlite3Pragma(Parse*,Token*,Token*,Token*,int); #ifndef SQLITE_OMIT_VIRTUALTABLE Module *sqlite3PragmaVtabRegister(sqlite3*,const char *zName); |