]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Prevent winOpenSharedMemory from masking the real return code from its call to winOpe...
authormistachkin <mistachkin@noemail.net>
Wed, 11 Jan 2012 01:01:02 +0000 (01:01 +0000)
committermistachkin <mistachkin@noemail.net>
Wed, 11 Jan 2012 01:01:02 +0000 (01:01 +0000)
FossilOrigin-Name: 93a65776dc8f496485e206a5eab11eeba579b5da

manifest
manifest.uuid
src/os_win.c

index b479465252c180baefad9813cca6441d534f6308..c3da4092bcea7f94fc916defb2d7963dda25cd6e 100644 (file)
--- 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
index a1133a352d61f6273791a5fd2f2399f11a5d1b6b..b5eb5de0d98468d20cf1e660945be7072e3d0beb 100644 (file)
@@ -1 +1 @@
-d0a868607e8f46941ece9f9d7b8ba220a7fb4e2b
\ No newline at end of file
+93a65776dc8f496485e206a5eab11eeba579b5da
\ No newline at end of file
index edac170b96800abdf72ddc931612855769f5ef94..8b86c7ed59f6e6ca5561540b0f939d671bfbd9fa 100644 (file)
@@ -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 ){