mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-08 14:02:16 +03:00
Ensure that the main filename and the journal filenames in the pager
object are all correctly double-zero terminated. FossilOrigin-Name: df51ae19c1aa4c26f2dcd427eddc1c9cc24b698e1ab0a948b198a57432e25e1e
This commit is contained in:
16
manifest
16
manifest
@@ -1,5 +1,5 @@
|
||||
C Remove\sa\sharmless\sunused\svariable.
|
||||
D 2019-11-12T03:45:23.554
|
||||
C Ensure\sthat\sthe\smain\sfilename\sand\sthe\sjournal\sfilenames\sin\sthe\spager\nobject\sare\sall\scorrectly\sdouble-zero\sterminated.
|
||||
D 2019-11-12T14:43:47.100
|
||||
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
||||
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
||||
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
|
||||
@@ -490,7 +490,7 @@ F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71
|
||||
F src/insert.c 8701d80b3cecd47f0375483c1ef35dfcdc777f3c67e2d3581dd7841b980910a3
|
||||
F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa
|
||||
F src/loadext.c 4ddc65ae13c0d93db0ceedc8b14a28c8c260513448b0eb8c5a2ac375e3b6a85d
|
||||
F src/main.c 20c6325c581123b8771ecb938f60d7e31c8152be01b4bf8e5eefbb74671ea86f
|
||||
F src/main.c 1505735106a694a6a62f28d912de74c5fe3dfbacdd3aa78a63eb97d0754f8b49
|
||||
F src/malloc.c b7640bcf8992cf2e98447da0d27e372abdc4621a6760418bad6d1470f041ada9
|
||||
F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645
|
||||
F src/mem1.c c12a42539b1ba105e3707d0e628ad70e611040d8f5e38cf942cee30c867083de
|
||||
@@ -513,7 +513,7 @@ F src/os_setup.h 0dbaea40a7d36bf311613d31342e0b99e2536586
|
||||
F src/os_unix.c a76a75f179cb233d54e505c3e0c84832224cfe5dfb3ee470bdcaf1ed29da57ab
|
||||
F src/os_win.c 035a813cbd17f355bdcad7ab894af214a9c13a1db8aeac902365350b98cd45a7
|
||||
F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a
|
||||
F src/pager.c 422fd8cfa59fb9173eff36a95878904a0eeb0dcc62ba49350acc8b1e51c4dc7b
|
||||
F src/pager.c 122d1e3e79424166d27a3a2768260bc613ac5acf99ea523f6127292636a589ed
|
||||
F src/pager.h 217921e81eb5fe455caa5cda96061959706bcdd29ddb57166198645ef7822ac3
|
||||
F src/parse.y 17c1ae265e1b92cb1f3f1661b020e3eb31f2d8b9588322d2b6f2b22f25b674c9
|
||||
F src/pcache.c 385ff064bca69789d199a98e2169445dc16e4291fa807babd61d4890c3b34177
|
||||
@@ -531,7 +531,7 @@ F src/shell.c.in c06961f202f3cc50b819744b7331d3caea3d79d958402f4900b066824855746
|
||||
F src/sqlite.h.in 5ba20664cede7f4e6861541fad1f17bac50f7bf576b40a8784c54f9126a9edd4
|
||||
F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
|
||||
F src/sqlite3ext.h cef696ce3293242c67b2339763608427bf72ee66f1f3a05389ac2a7b46001c31
|
||||
F src/sqliteInt.h 4edb543eea01329566c4050b238757b7ab70dc934ec4b26119aa20931eacc486
|
||||
F src/sqliteInt.h 7015c75411f4df4cc5f694ce68feab6ec32a42189517aacc692f4757d54d2008
|
||||
F src/sqliteLimit.h 1513bfb7b20378aa0041e7022d04acb73525de35b80b252f1b83fedb4de6a76b
|
||||
F src/status.c 46e7aec11f79dad50965a5ca5fa9de009f7d6bde08be2156f1538a0a296d4d0e
|
||||
F src/table.c b46ad567748f24a326d9de40e5b9659f96ffff34
|
||||
@@ -1849,7 +1849,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
|
||||
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
||||
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
||||
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
||||
P 8e100e6c35c30e0d7e4014b9435f81f9f61ddab2386dfe9a4218d8190a6da3be
|
||||
R 025998a1c2a58ed56e4d9b964b304926
|
||||
P 28091a48aa6994f8d7c142b5851bcd6b4e9a93a7bbef6c927a6182d24f3245b4
|
||||
R 0451857d71a08492adf8df03311a6e2f
|
||||
U drh
|
||||
Z 3ed8d6a5cf92887ef89b728e90a08c3f
|
||||
Z 43dce68710a14946b20ee1369e8095d5
|
||||
|
@@ -1 +1 @@
|
||||
28091a48aa6994f8d7c142b5851bcd6b4e9a93a7bbef6c927a6182d24f3245b4
|
||||
df51ae19c1aa4c26f2dcd427eddc1c9cc24b698e1ab0a948b198a57432e25e1e
|
19
src/main.c
19
src/main.c
@@ -4187,6 +4187,25 @@ int sqlite3_test_control(int op, ...){
|
||||
return rc;
|
||||
}
|
||||
|
||||
#ifdef SQLITE_DEBUG
|
||||
/*
|
||||
** This routine appears inside assert() statements only.
|
||||
**
|
||||
** Return the number of URI parameters that follow the filename.
|
||||
*/
|
||||
int sqlite3UriCount(const char *z){
|
||||
int n = 0;
|
||||
if( z==0 ) return 0;
|
||||
z += strlen(z)+1;
|
||||
while( z[0] ){
|
||||
z += strlen(z)+1;
|
||||
z += strlen(z)+1;
|
||||
n++;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
#endif /* SQLITE_DEBUG */
|
||||
|
||||
/*
|
||||
** This is a utility routine, useful to VFS implementations, that checks
|
||||
** to see if a database file was a URI that contained a specific query
|
||||
|
31
src/pager.c
31
src/pager.c
@@ -4760,7 +4760,10 @@ int sqlite3PagerOpen(
|
||||
int pcacheSize = sqlite3PcacheSize(); /* Bytes to allocate for PCache */
|
||||
u32 szPageDflt = SQLITE_DEFAULT_PAGE_SIZE; /* Default page size */
|
||||
const char *zUri = 0; /* URI args to copy */
|
||||
int nUri = 0; /* Number of bytes of URI args at *zUri */
|
||||
int nUriByte = 1; /* Number of bytes of URI args at *zUri */
|
||||
#ifdef SQLITE_DEBUG
|
||||
int nUri = 0; /* Number of URI parameters */
|
||||
#endif
|
||||
|
||||
/* Figure out how much space is required for each journal file-handle
|
||||
** (there are two of them, the main journal and the sub-journal). */
|
||||
@@ -4797,11 +4800,14 @@ int sqlite3PagerOpen(
|
||||
nPathname = sqlite3Strlen30(zPathname);
|
||||
z = zUri = &zFilename[sqlite3Strlen30(zFilename)+1];
|
||||
while( *z ){
|
||||
z += sqlite3Strlen30(z)+1;
|
||||
z += sqlite3Strlen30(z)+1;
|
||||
z += strlen(z)+1;
|
||||
z += strlen(z)+1;
|
||||
#ifdef SQLITE_DEBUG
|
||||
nUri++;
|
||||
#endif
|
||||
}
|
||||
nUri = (int)(&z[1] - zUri);
|
||||
assert( nUri>=0 );
|
||||
nUriByte = (int)(&z[2] - zUri);
|
||||
assert( nUriByte>=1 );
|
||||
if( rc==SQLITE_OK && nPathname+8>pVfs->mxPathname ){
|
||||
/* This branch is taken when the journal path required by
|
||||
** the database being opened will be more than pVfs->mxPathname
|
||||
@@ -4834,7 +4840,7 @@ int sqlite3PagerOpen(
|
||||
ROUND8(pcacheSize) + /* PCache object */
|
||||
ROUND8(pVfs->szOsFile) + /* The main db file */
|
||||
journalFileSize * 2 + /* The two journal files */
|
||||
nPathname + 1 + nUri + /* zFilename */
|
||||
nPathname + 1 + nUriByte + /* zFilename */
|
||||
nPathname + 8 + 2 /* zJournal */
|
||||
#ifndef SQLITE_OMIT_WAL
|
||||
+ nPathname + 4 + 2 /* zWal */
|
||||
@@ -4856,18 +4862,21 @@ int sqlite3PagerOpen(
|
||||
/* Fill in the Pager.zFilename and Pager.zJournal buffers, if required. */
|
||||
if( zPathname ){
|
||||
assert( nPathname>0 );
|
||||
pPager->zJournal = (char*)(pPtr += nPathname + 1 + nUri);
|
||||
memcpy(pPager->zFilename, zPathname, nPathname);
|
||||
if( nUri ) memcpy(&pPager->zFilename[nPathname+1], zUri, nUri);
|
||||
if( nUri ) memcpy(&pPager->zFilename[nPathname+1], zUri, nUriByte);
|
||||
pPager->zJournal = (char*)(pPtr += nPathname + 1 + nUriByte);
|
||||
memcpy(pPager->zJournal, zPathname, nPathname);
|
||||
memcpy(&pPager->zJournal[nPathname], "-journal\000", 8+2);
|
||||
memcpy(&pPager->zJournal[nPathname], "-journal", 8);
|
||||
sqlite3FileSuffix3(pPager->zFilename, pPager->zJournal);
|
||||
#ifndef SQLITE_OMIT_WAL
|
||||
pPager->zWal = &pPager->zJournal[nPathname+8+1];
|
||||
pPager->zWal = (char*)(pPtr += nPathname + 8 + 2);
|
||||
memcpy(pPager->zWal, zPathname, nPathname);
|
||||
memcpy(&pPager->zWal[nPathname], "-wal\000", 4+1);
|
||||
memcpy(&pPager->zWal[nPathname], "-wal", 4);
|
||||
sqlite3FileSuffix3(pPager->zFilename, pPager->zWal);
|
||||
assert( sqlite3UriCount(pPager->zWal)==0 );
|
||||
#endif
|
||||
assert( sqlite3UriCount(pPager->zFilename)==nUri );
|
||||
assert( sqlite3UriCount(pPager->zJournal)==0 );
|
||||
sqlite3DbFree(0, zPathname);
|
||||
}
|
||||
pPager->pVfs = pVfs;
|
||||
|
@@ -3992,6 +3992,9 @@ void sqlite3AddDefaultValue(Parse*,Expr*,const char*,const char*);
|
||||
void sqlite3AddCollateType(Parse*, Token*);
|
||||
void sqlite3AddGenerated(Parse*,Expr*,Token*);
|
||||
void sqlite3EndTable(Parse*,Token*,Token*,u8,Select*);
|
||||
#ifdef SQLITE_DEBUG
|
||||
int sqlite3UriCount(const char*);
|
||||
#endif
|
||||
int sqlite3ParseUri(const char*,const char*,unsigned int*,
|
||||
sqlite3_vfs**,char**,char **);
|
||||
#ifdef SQLITE_HAS_CODEC
|
||||
|
Reference in New Issue
Block a user