1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-09 14:21:03 +03:00

Make sure filenames passed into sqlite3OsOpen() always have the extra

zero-terminators needed by sqlite3_uri_parameter().

FossilOrigin-Name: d73e93cfdc9441ade77b796dcdcf6eeb753cb398
This commit is contained in:
drh
2012-01-03 14:50:45 +00:00
parent 8942d4125e
commit 52bcde0e2d
7 changed files with 25 additions and 20 deletions

View File

@@ -1164,6 +1164,10 @@ int sqlite3AbsInt32(int x){
** If SQLITE_ENABLE_8_3_NAMES is set to 2 at compile-time, then always
** do the suffix shortening regardless of URI parameter.
**
** Assume that zBaseFilename contains two \000 terminator bytes (so that
** it can be harmlessly passed into sqlite3_uri_parameter()) and copy both
** zero terminator bytes into the end of the revised name.
**
** Examples:
**
** test.db-journal => test.nal
@@ -1172,6 +1176,7 @@ int sqlite3AbsInt32(int x){
** test.db-mj7f3319fa => test.9fa
*/
void sqlite3FileSuffix3(const char *zBaseFilename, char *z){
assert( zBaseFilename[strlen(zBaseFilename)+1]==0 );
#if SQLITE_ENABLE_8_3_NAMES<2
if( sqlite3_uri_boolean(zBaseFilename, "8_3_names", 0) )
#endif
@@ -1179,7 +1184,7 @@ void sqlite3FileSuffix3(const char *zBaseFilename, char *z){
int i, sz;
sz = sqlite3Strlen30(z);
for(i=sz-1; i>0 && z[i]!='/' && z[i]!='.'; i--){}
if( z[i]=='.' && ALWAYS(sz>i+4) ) memmove(&z[i+1], &z[sz-3], 4);
if( z[i]=='.' && ALWAYS(sz>i+4) ) memmove(&z[i+1], &z[sz-3], 5);
}
}
#endif