]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
The MAX_PATH constant in windows is measured in characters, so multiple by 3
authordrh <drh@noemail.net>
Wed, 31 Jul 2013 19:55:25 +0000 (19:55 +0000)
committerdrh <drh@noemail.net>
Wed, 31 Jul 2013 19:55:25 +0000 (19:55 +0000)
to get the number of bytes assuming worst-case UTF8 pathnames.

FossilOrigin-Name: bb06e1579022c24546ac5117a99846b3c37ef59b

manifest
manifest.uuid
src/os_win.c

index 327c096cff5f83a39f9bc3b5e9f2e3f7e162b35a..af4b04bd88e97725e7a043c894d30963bebb604a 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Reduce\sthe\ssize\sof\sthe\sstack\srequired\sby\sthe\scodeOneLoopStart()\sfunction\sin\nwhere.c.
-D 2013-07-30T15:10:32.747
+C The\sMAX_PATH\sconstant\sin\swindows\sis\smeasured\sin\scharacters,\sso\smultiple\sby\s3\nto\sget\sthe\snumber\sof\sbytes\sassuming\sworst-case\sUTF8\spathnames.
+D 2013-07-31T19:55:25.865
 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
 F Makefile.in 5e41da95d92656a5004b03d3576e8b226858a28e
 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -203,7 +203,7 @@ F src/os.c b4ad71336fd96f97776f75587cd9e8218288f5be
 F src/os.h 4a46270a64e9193af4a0aaa3bc2c66dc07c29b3f
 F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04
 F src/os_unix.c 9eafa5458cf2ff684ddccff82c9bb113c7cad847
-F src/os_win.c 074cb2b9bca6a1c2bd72acf04666cdc554bfaa9b
+F src/os_win.c d0e9774f6dd3975cda31594049ab8216c2d6978b
 F src/pager.c 5d2f7475260a8588f9c441bb309d2b7eaa7ded3b
 F src/pager.h 5cb78b8e1adfd5451e600be7719f5a99d87ac3b1
 F src/parse.y 9acfcc83ddbf0cf82f0ed9582ccf0ad6c366ff37
@@ -1103,7 +1103,7 @@ F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381
 F tool/wherecosttest.c f407dc4c79786982a475261866a161cd007947ae
 F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac
-P 9e819f0f12b6f2a8e0e7a90251b3115ff1595f25
-R 8a77f3488eeca7f033bc07ab4b9db562
+P eb6d4278b8516e0571269049d1eaa55066f51b1a
+R d0484fd8b656e8cf7cd4ab3eed43ed22
 U drh
-Z 51b3ad13ced3eb326ea64314852a899d
+Z 0de91cecc0135d1602cf04652b34abe4
index 116c2adffeff308bb595bad9d62c2dcf0a46a723..ade4fc36814e9e1e3a18ad14e9e5b04b891a9f60 100644 (file)
@@ -1 +1 @@
-eb6d4278b8516e0571269049d1eaa55066f51b1a
\ No newline at end of file
+bb06e1579022c24546ac5117a99846b3c37ef59b
\ No newline at end of file
index bdf025aa4ce80e2eb030e79d68a2833e0aa60f8a..b8136f0e9c2ebeefe6c1cf7102dc8225b8aacba5 100644 (file)
@@ -230,6 +230,7 @@ struct winFile {
 #  define SQLITE_WIN32_HEAP_FLAGS     (0)
 #endif
 
+
 /*
 ** The winMemData structure stores information required by the Win32-specific
 ** sqlite3_mem_methods implementation.
@@ -3866,6 +3867,15 @@ static void *convertUtf8Filename(const char *zFilename){
   return zConverted;
 }
 
+/*
+** Maximum pathname length (in bytes) for windows.  The MAX_PATH macro is
+** in characters, so we allocate 3 bytes per character assuming worst-case
+** 3-bytes-per-character UTF8.
+*/
+#ifndef SQLITE_WIN32_MAX_PATH
+#  define SQLITE_WIN32_MAX_PATH   (MAX_PATH*3)
+#endif
+
 /*
 ** Create a temporary file name in zBuf.  zBuf must be big enough to
 ** hold at pVfs->mxPathname characters.
@@ -3877,7 +3887,7 @@ static int getTempname(int nBuf, char *zBuf){
     "0123456789";
   size_t i, j;
   int nTempPath;
-  char zTempPath[MAX_PATH+2];
+  char zTempPath[SQLITE_WIN32_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
@@ -3885,10 +3895,11 @@ static int getTempname(int nBuf, char *zBuf){
   */
   SimulateIOError( return SQLITE_IOERR );
 
-  memset(zTempPath, 0, MAX_PATH+2);
+  memset(zTempPath, 0, SQLITE_WIN32_MAX_PATH+2);
 
   if( sqlite3_temp_directory ){
-    sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", sqlite3_temp_directory);
+    sqlite3_snprintf(SQLITE_WIN32_MAX_PATH-30, zTempPath, "%s",
+                     sqlite3_temp_directory);
   }
 #if !SQLITE_OS_WINRT
   else if( isNT() ){
@@ -3897,7 +3908,7 @@ static int getTempname(int nBuf, char *zBuf){
     osGetTempPathW(MAX_PATH-30, zWidePath);
     zMulti = unicodeToUtf8(zWidePath);
     if( zMulti ){
-      sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", zMulti);
+      sqlite3_snprintf(SQLITE_WIN32_MAX_PATH-30, zTempPath, "%s", zMulti);
       sqlite3_free(zMulti);
     }else{
       OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n"));
@@ -3907,11 +3918,11 @@ static int getTempname(int nBuf, char *zBuf){
 #ifdef SQLITE_WIN32_HAS_ANSI
   else{
     char *zUtf8;
-    char zMbcsPath[MAX_PATH];
-    osGetTempPathA(MAX_PATH-30, zMbcsPath);
+    char zMbcsPath[SQLITE_WIN32_MAX_PATH];
+    osGetTempPathA(SQLITE_WIN32_MAX_PATH-30, zMbcsPath);
     zUtf8 = sqlite3_win32_mbcs_to_utf8(zMbcsPath);
     if( zUtf8 ){
-      sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", zUtf8);
+      sqlite3_snprintf(SQLITE_WIN32_MAX_PATH-30, zTempPath, "%s", zUtf8);
       sqlite3_free(zUtf8);
     }else{
       OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n"));
@@ -4005,7 +4016,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+2];     /* Buffer used to create temp filename */
+  char zTmpname[SQLITE_WIN32_MAX_PATH+2];     /* Buffer used to create temp filename */
 
   int rc = SQLITE_OK;            /* Function Return Code */
 #if !defined(NDEBUG) || SQLITE_OS_WINCE
@@ -4071,8 +4082,8 @@ static int winOpen(
   */
   if( !zUtf8Name ){
     assert(isDelete && !isOpenJournal);
-    memset(zTmpname, 0, MAX_PATH+2);
-    rc = getTempname(MAX_PATH+2, zTmpname);
+    memset(zTmpname, 0, SQLITE_WIN32_MAX_PATH+2);
+    rc = getTempname(SQLITE_WIN32_MAX_PATH+2, zTmpname);
     if( rc!=SQLITE_OK ){
       OSTRACE(("OPEN name=%s, rc=%s", zUtf8Name, sqlite3ErrName(rc)));
       return rc;
@@ -4503,7 +4514,7 @@ static int winFullPathname(
 #if defined(__CYGWIN__)
   SimulateIOError( return SQLITE_ERROR );
   UNUSED_PARAMETER(nFull);
-  assert( pVfs->mxPathname>=MAX_PATH );
+  assert( pVfs->mxPathname>=SQLITE_WIN32_MAX_PATH );
   assert( nFull>=pVfs->mxPathname );
   if ( sqlite3_data_directory && !winIsVerbatimPathname(zRelative) ){
     /*
@@ -4512,10 +4523,10 @@ static int winFullPathname(
     **       for converting the relative path name to an absolute
     **       one by prepending the data directory and a slash.
     */
-    char zOut[MAX_PATH+1];
-    memset(zOut, 0, MAX_PATH+1);
+    char zOut[SQLITE_WIN32_MAX_PATH+1];
+    memset(zOut, 0, SQLITE_WIN32_MAX_PATH+1);
     cygwin_conv_path(CCP_POSIX_TO_WIN_A|CCP_RELATIVE, zRelative, zOut,
-                     MAX_PATH+1);
+                     SQLITE_WIN32_MAX_PATH+1);
     sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s\\%s",
                      sqlite3_data_directory, zOut);
   }else{
@@ -4861,7 +4872,7 @@ int sqlite3_os_init(void){
   static sqlite3_vfs winVfs = {
     3,                   /* iVersion */
     sizeof(winFile),     /* szOsFile */
-    MAX_PATH,            /* mxPathname */
+    SQLITE_WIN32_MAX_PATH, /* mxPathname */
     0,                   /* pNext */
     "win32",             /* zName */
     0,                   /* pAppData */