From: mistachkin Date: Wed, 11 Jan 2012 01:01:02 +0000 (+0000) Subject: Prevent winOpenSharedMemory from masking the real return code from its call to winOpe... X-Git-Tag: version-3.7.10~17 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e290919ae2a9c3450af76af1fa56df4be609e445;p=thirdparty%2Fsqlite.git Prevent winOpenSharedMemory from masking the real return code from its call to winOpen. Also, add asserts to check the double-zero termination of database file names. FossilOrigin-Name: 93a65776dc8f496485e206a5eab11eeba579b5da --- diff --git a/manifest b/manifest index b479465252..c3da4092bc 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Make\ssure\sfilenames\shanded\sto\sthe\sVFS\sby\sthe\sfake_big_file\stest\sprocedure\nare\sdouble-zero\sterminated. -D 2012-01-11T00:38:51.026 +C Prevent\swinOpenSharedMemory\sfrom\smasking\sthe\sreal\sreturn\scode\sfrom\sits\scall\sto\swinOpen.\s\sAlso,\sadd\sasserts\sto\scheck\sthe\sdouble-zero\stermination\sof\sdatabase\sfile\snames. +D 2012-01-11T01:01:02.707 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5b4a3e12a850b021547e43daf886b25133b44c07 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -167,7 +167,7 @@ F src/os.h a2219c3b05ce31230bb000fdc4f1a542b33ee649 F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04 F src/os_os2.c 4a75888ba3dfc820ad5e8177025972d74d7f2440 F src/os_unix.c 657672fab2580a84116c140b36ee3d6b6fc75b4e -F src/os_win.c e344ccb73aaeb5caab2c3419fba2857f914198d7 +F src/os_win.c 5ac061ae1326a71500cee578ed0fd9113b4f6a37 F src/pager.c 99ee9e52e48bd42bd7523968017c057b93d75df9 F src/pager.h 5cd760857707529b403837d813d86b68938d6183 F src/parse.y fabb2e7047417d840e6fdb3ef0988a86849a08ba @@ -986,7 +986,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh 9f406d66e750e8ac031c63a9ef3248aaa347ef2a F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P cb774b26e13745cfad0d76a71e47466d703e0007 -R 780bf2e97bf51fe59b326674e184191e -U drh -Z 3db9953fe728ac89f28aade46f63b156 +P d0a868607e8f46941ece9f9d7b8ba220a7fb4e2b +R 22997c9d805abc30d95375b077a30497 +U mistachkin +Z dd5ebb5a1b41f14f902314717dcdb894 diff --git a/manifest.uuid b/manifest.uuid index a1133a352d..b5eb5de0d9 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d0a868607e8f46941ece9f9d7b8ba220a7fb4e2b \ No newline at end of file +93a65776dc8f496485e206a5eab11eeba579b5da \ No newline at end of file diff --git a/src/os_win.c b/src/os_win.c index edac170b96..8b86c7ed59 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -2506,7 +2506,6 @@ static int winOpenSharedMemory(winFile *pDbFd){ SQLITE_OPEN_WAL | SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, /* Mode flags */ 0); if( SQLITE_OK!=rc ){ - rc = SQLITE_CANTOPEN_BKPT; goto shm_open_err; } @@ -2929,7 +2928,7 @@ static int getTempname(int nBuf, char *zBuf){ "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "0123456789"; size_t i, j; - char zTempPath[MAX_PATH+1]; + char zTempPath[MAX_PATH+2]; /* It's odd to simulate an io-error here, but really this is just ** using the io-error infrastructure to test that SQLite handles this @@ -2972,14 +2971,14 @@ static int getTempname(int nBuf, char *zBuf){ /* Check that the output buffer is large enough for the temporary file ** name. If it is not, return SQLITE_ERROR. */ - if( (sqlite3Strlen30(zTempPath) + sqlite3Strlen30(SQLITE_TEMP_FILE_PREFIX) + 17) >= nBuf ){ + if( (sqlite3Strlen30(zTempPath) + sqlite3Strlen30(SQLITE_TEMP_FILE_PREFIX) + 18) >= nBuf ){ return SQLITE_ERROR; } for(i=sqlite3Strlen30(zTempPath); i>0 && zTempPath[i-1]=='\\'; i--){} zTempPath[i] = 0; - sqlite3_snprintf(nBuf-17, zBuf, + sqlite3_snprintf(nBuf-18, zBuf, "%s\\"SQLITE_TEMP_FILE_PREFIX, zTempPath); j = sqlite3Strlen30(zBuf); sqlite3_randomness(15, &zBuf[j]); @@ -2987,6 +2986,7 @@ static int getTempname(int nBuf, char *zBuf){ zBuf[j] = (char)zChars[ ((unsigned char)zBuf[j])%(sizeof(zChars)-1) ]; } zBuf[j] = 0; + zBuf[j+1] = 0; OSTRACE(("TEMP FILENAME: %s\n", zBuf)); return SQLITE_OK; @@ -3019,7 +3019,7 @@ static int winOpen( /* If argument zPath is a NULL pointer, this function is required to open ** a temporary file. Use this buffer to store the file name in. */ - char zTmpname[MAX_PATH+1]; /* Buffer used to create temp filename */ + char zTmpname[MAX_PATH+2]; /* Buffer used to create temp filename */ int rc = SQLITE_OK; /* Function Return Code */ #if !defined(NDEBUG) || SQLITE_OS_WINCE @@ -3078,13 +3078,20 @@ static int winOpen( */ if( !zUtf8Name ){ assert(isDelete && !isOpenJournal); - rc = getTempname(MAX_PATH+1, zTmpname); + rc = getTempname(MAX_PATH+2, zTmpname); if( rc!=SQLITE_OK ){ return rc; } zUtf8Name = zTmpname; } + /* Database filenames are double-zero terminated if they are not + ** URIs with parameters. Hence, they can always be passed into + ** sqlite3_uri_parameter(). + */ + assert( (eType!=SQLITE_OPEN_MAIN_DB) || (flags & SQLITE_OPEN_URI) || + zUtf8Name[strlen(zUtf8Name)+1]==0 ); + /* Convert the filename to the system encoding. */ zConverted = convertUtf8Filename(zUtf8Name); if( zConverted==0 ){