Have test_multiplex.c add a second nul-terminator byte to the strings that it passes to the xOpen method of the underlying VFS, in case that VFS passes the string to sqlite3_uri_parameter() or similar.

FossilOrigin-Name: 12f5b8c9c9a15bd9e6aabdc708d4e869ff918e76
This commit is contained in:
dan 2012-01-09 11:37:34 +00:00
parent 45d29309a7
commit 730f85a34e
4 changed files with 37 additions and 15 deletions

View File

@ -1,5 +1,5 @@
C Fix\stypos\sin\scommands.\s\sCombine\sthe\sExpandBlob\sand\sexpandBlob\smacros\sinto\sone.
D 2012-01-08T22:18:33.638
C Have\stest_multiplex.c\sadd\sa\ssecond\snul-terminator\sbyte\sto\sthe\sstrings\sthat\sit\spasses\sto\sthe\sxOpen\smethod\sof\sthe\sunderlying\sVFS,\sin\scase\sthat\sVFS\spasses\sthe\sstring\sto\ssqlite3_uri_parameter()\sor\ssimilar.
D 2012-01-09T11:37:34.923
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in 5b4a3e12a850b021547e43daf886b25133b44c07
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@ -214,7 +214,7 @@ F src/test_intarray.h 489edb9068bb926583445cb02589344961054207
F src/test_journal.c 2c06e4be6584d51b935dc8b353980a9388de62ef
F src/test_loadext.c df586c27176e3c2cb2e099c78da67bf14379a56e
F src/test_malloc.c 8d416f29ad8573f32601f6056c9d2b17472e9ad5
F src/test_multiplex.c 2bf2eb36c9eff73c808ba6d19388e2f577438d9e
F src/test_multiplex.c 5dc22dbeb43b304373b6d5c6fe6ea295d78caf02
F src/test_multiplex.h e99c571bc4968b7a9363b661481f3934bfead61d
F src/test_mutex.c a6bd7b9cf6e19d989e31392b06ac8d189f0d573e
F src/test_onefile.c 40cf9e212a377a6511469384a64b01e6e34b2eec
@ -630,7 +630,7 @@ F test/pageropt.test 9191867ed19a2b3db6c42d1b36b6fbc657cd1ab0
F test/pagesize.test 1dd51367e752e742f58e861e65ed7390603827a0
F test/pcache.test 065aa286e722ab24f2e51792c1f093bf60656b16
F test/pcache2.test a83efe2dec0d392f814bfc998def1d1833942025
F test/permutations.test 8db6d3b72e6ce423cfb94d87926e5edcb4b0078f
F test/permutations.test 0f40a13ba43170a0f4e179c9ac0b77bc87c490fe
F test/pragma.test 7fa35e53085812dac94c2bfcbb02c2a4ad35df5e
F test/pragma2.test 3a55f82b954242c642f8342b17dffc8b47472947
F test/printf.test ec9870c4dce8686a37818e0bf1aba6e6a1863552
@ -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 429380f99c59ca10de18638ce6f9ec7c47082999
R 9b790a47dcff0bf2c5786bcb4562c116
U drh
Z 8f90de0c23a8df1cb3585afb30babe53
P fc9179e154751b51ddef429600d30a89d4a098bd
R b97de21d05351bae95745d0c83332eb7
U dan
Z 54c888cc6eca4296547cf85c4dc77f0c

View File

@ -1 +1 @@
fc9179e154751b51ddef429600d30a89d4a098bd
12f5b8c9c9a15bd9e6aabdc708d4e869ff918e76

View File

@ -220,9 +220,27 @@ static int multiplexStrlen30(const char *z){
/*
** Generate the file-name for chunk iChunk of the group with base name
** zBase. The file-name is written to buffer zOut before returning. Buffer
** zOut must be allocated by the caller so that it is at least (nBase+4)
** zOut must be allocated by the caller so that it is at least (nBase+5)
** bytes in size, where nBase is the length of zBase, not including the
** nul-terminator.
**
** If iChunk is 0 (or 400 - the number for the first journal file chunk),
** the output is a copy of the input string. Otherwise, if
** SQLITE_ENABLE_8_3_NAMES is not defined or the input buffer does not contain
** a "." character, then the output is a copy of the input string with the
** three-digit zero-padded decimal representation if iChunk appended to it.
** For example:
**
** zBase="test.db", iChunk=4 -> zOut="test.db004"
**
** Or, if SQLITE_ENABLE_8_3_NAMES is defined and the input buffer contains
** a "." character, then everything after the "." is replaced by the
** three-digit representation of iChunk.
**
** zBase="test.db", iChunk=4 -> zOut="test.004"
**
** The output buffer string is terminated by 2 0x00 bytes. This makes it safe
** to pass to sqlite3_uri_parameter() and similar.
*/
static void multiplexFilename(
const char *zBase, /* Filename for chunk 0 */
@ -231,9 +249,9 @@ static void multiplexFilename(
int iChunk, /* Chunk to generate filename for */
char *zOut /* Buffer to write generated name to */
){
memcpy(zOut, zBase, nBase+1);
int n = nBase;
memcpy(zOut, zBase, n+1);
if( iChunk!=0 && iChunk!=SQLITE_MULTIPLEX_JOURNAL_8_3_OFFSET ){
int n = nBase;
#ifdef SQLITE_ENABLE_8_3_NAMES
int i;
for(i=n-1; i>0 && i>=n-4 && zOut[i]!='.'; i--){}
@ -247,7 +265,11 @@ static void multiplexFilename(
}
#endif
sqlite3_snprintf(4,&zOut[n],"%03d",iChunk);
n += 3;
}
assert( zOut[n]=='\0' );
zOut[n+1] = '\0';
}
/* Compute the filename for the iChunk-th chunk
@ -266,7 +288,7 @@ static int multiplexSubFilename(multiplexGroup *pGroup, int iChunk){
if( pGroup->zName && pGroup->aReal[iChunk].z==0 ){
char *z;
int n = pGroup->nName;
pGroup->aReal[iChunk].z = z = sqlite3_malloc( n+4 );
pGroup->aReal[iChunk].z = z = sqlite3_malloc( n+5 );
if( z==0 ){
return SQLITE_NOMEM;
}
@ -611,7 +633,7 @@ static int multiplexDelete(
*/
int nName = strlen(zName);
char *z;
z = sqlite3_malloc(nName + 4);
z = sqlite3_malloc(nName + 5);
if( z==0 ){
rc = SQLITE_IOERR_NOMEM;
}else{

View File

@ -142,7 +142,7 @@ test_suite "valgrind" -prefix "" -description {
Run the "veryquick" test suite with a couple of multi-process tests (that
fail under valgrind) omitted.
} -files [
test_set $allquicktests -exclude *malloc* *ioerr* *fault*
test_set $allquicktests -exclude *malloc* *ioerr* *fault* wal.test
] -initialize {
set ::G(valgrind) 1
} -shutdown {