aboutsummaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2020-02-01 13:30:39 +0000
committerdrh <drh@noemail.net>2020-02-01 13:30:39 +0000
commit1eac966076301c782811314677edaaa173f7bf83 (patch)
tree52bace0620ab959e363512bf3ce5398e7e3f86d9 /src/main.c
parent562fd18b9dc27216191c0a6477bba9b175f7f0d2 (diff)
downloadsqlite-1eac966076301c782811314677edaaa173f7bf83.tar.gz
sqlite-1eac966076301c782811314677edaaa173f7bf83.zip
Fix a problem in sqlite3CodecQueryParameters() that was introduced by the
query parameter encoding changes for the 3.31.1 release. FossilOrigin-Name: cc65ca541265bd7061ed8f5ec9a54f3c384c41019c5ea1c68dcaabeff3495839
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c32
1 files changed, 21 insertions, 11 deletions
diff --git a/src/main.c b/src/main.c
index 3983f083b..528e9a770 100644
--- a/src/main.c
+++ b/src/main.c
@@ -2989,6 +2989,21 @@ int sqlite3ParseUri(
return rc;
}
+/*
+** This routine does the core work of extracting URI parameters from a
+** database filename for the sqlite3_uri_parameter() interface.
+*/
+static const char *uriParameter(const char *zFilename, const char *zParam){
+ zFilename += sqlite3Strlen30(zFilename) + 1;
+ while( zFilename[0] ){
+ int x = strcmp(zFilename, zParam);
+ zFilename += sqlite3Strlen30(zFilename) + 1;
+ if( x==0 ) return zFilename;
+ zFilename += sqlite3Strlen30(zFilename) + 1;
+ }
+ return 0;
+}
+
#if defined(SQLITE_HAS_CODEC)
/*
** Process URI filename query parameters relevant to the SQLite Encryption
@@ -3001,7 +3016,9 @@ int sqlite3CodecQueryParameters(
const char *zUri /* URI filename */
){
const char *zKey;
- if( (zKey = sqlite3_uri_parameter(zUri, "hexkey"))!=0 && zKey[0] ){
+ if( zUri==0 ){
+ return 0;
+ }else if( (zKey = uriParameter(zUri, "hexkey"))!=0 && zKey[0] ){
u8 iByte;
int i;
char zDecoded[40];
@@ -3011,10 +3028,10 @@ int sqlite3CodecQueryParameters(
}
sqlite3_key_v2(db, zDb, zDecoded, i/2);
return 1;
- }else if( (zKey = sqlite3_uri_parameter(zUri, "key"))!=0 ){
+ }else if( (zKey = uriParameter(zUri, "key"))!=0 ){
sqlite3_key_v2(db, zDb, zKey, sqlite3Strlen30(zKey));
return 1;
- }else if( (zKey = sqlite3_uri_parameter(zUri, "textkey"))!=0 ){
+ }else if( (zKey = uriParameter(zUri, "textkey"))!=0 ){
sqlite3_key_v2(db, zDb, zKey, -1);
return 1;
}else{
@@ -4272,14 +4289,7 @@ static const char *databaseName(const char *zName){
const char *sqlite3_uri_parameter(const char *zFilename, const char *zParam){
if( zFilename==0 || zParam==0 ) return 0;
zFilename = databaseName(zFilename);
- zFilename += sqlite3Strlen30(zFilename) + 1;
- while( zFilename[0] ){
- int x = strcmp(zFilename, zParam);
- zFilename += sqlite3Strlen30(zFilename) + 1;
- if( x==0 ) return zFilename;
- zFilename += sqlite3Strlen30(zFilename) + 1;
- }
- return 0;
+ return uriParameter(zFilename, zParam);
}
/*