1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-15 11:41:13 +03:00

Return a suitable error message if the mode= argument to a URI specifies

a higher mode than what is allowed by context.  Other minor cleanups for
the URI parsing logic.

FossilOrigin-Name: d9bc1c7fe0ca5f6973a85827330958f4d09f8171
This commit is contained in:
drh
2011-05-09 19:20:17 +00:00
parent ffd9668fb5
commit de941c3756
3 changed files with 16 additions and 13 deletions

View File

@@ -1,5 +1,5 @@
C Set\sthe\ssqlite3.mallocFailed\sflag\sif\ssqlite3ParseUri\sfails\swith\sSQLITE_NOMEM. C Return\sa\ssuitable\serror\smessage\sif\sthe\smode=\sargument\sto\sa\sURI\sspecifies\na\shigher\smode\sthan\swhat\sis\sallowed\sby\scontext.\s\sOther\sminor\scleanups\sfor\nthe\sURI\sparsing\slogic.
D 2011-05-07T18:40:36.334 D 2011-05-09T19:20:17.775
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in 7a4d9524721d40ef9ee26f93f9bd6a51dba106f2 F Makefile.in 7a4d9524721d40ef9ee26f93f9bd6a51dba106f2
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -144,7 +144,7 @@ F src/journal.c 552839e54d1bf76fb8f7abe51868b66acacf6a0e
F src/legacy.c a199d7683d60cef73089e892409113e69c23a99f F src/legacy.c a199d7683d60cef73089e892409113e69c23a99f
F src/lempar.c 7f026423f4d71d989e719a743f98a1cbd4e6d99e F src/lempar.c 7f026423f4d71d989e719a743f98a1cbd4e6d99e
F src/loadext.c 3ae0d52da013a6326310655be6473fd472347b85 F src/loadext.c 3ae0d52da013a6326310655be6473fd472347b85
F src/main.c c914afd2c37b7662acb5034c20465b807037b84c F src/main.c f00cee5a27f5df5ed536e7043cb451b3c85ce65c
F src/malloc.c 591aedb20ae40813f1045f2ef253438a334775d9 F src/malloc.c 591aedb20ae40813f1045f2ef253438a334775d9
F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645
F src/mem1.c 00bd8265c81abb665c48fea1e0c234eb3b922206 F src/mem1.c 00bd8265c81abb665c48fea1e0c234eb3b922206
@@ -935,7 +935,7 @@ F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
P 3c926ce0976e765b4c51fcd81d251268ff21a741 P ca3797d4967361e31a8a5ce1ce8190b095f3ed4c
R 469c4635a93084885b543f0cd5b2c5df R fbfaa47316ae48b91e92f26cbe2f2742
U drh U drh
Z c02f1d6b5c75b5c7abb8e8e853d0d67b Z 82e3dc394cc5052bfb9a5a6a21e4f298

View File

@@ -1 +1 @@
ca3797d4967361e31a8a5ce1ce8190b095f3ed4c d9bc1c7fe0ca5f6973a85827330958f4d09f8171

View File

@@ -1826,6 +1826,7 @@ int sqlite3ParseUri(
unsigned int flags = *pFlags; unsigned int flags = *pFlags;
const char *zVfs = zDefaultVfs; const char *zVfs = zDefaultVfs;
char *zFile; char *zFile;
char c;
int nUri = sqlite3Strlen30(zUri); int nUri = sqlite3Strlen30(zUri);
assert( *pzErrMsg==0 ); assert( *pzErrMsg==0 );
@@ -1873,8 +1874,8 @@ int sqlite3ParseUri(
** 2: Parsing value section of a name=value query parameter. ** 2: Parsing value section of a name=value query parameter.
*/ */
eState = 0; eState = 0;
while( zUri[iIn] && zUri[iIn]!='#' ){ while( (c = zUri[iIn])!=0 && c!='#' ){
char c = zUri[iIn++]; iIn++;
if( c=='%' if( c=='%'
&& sqlite3Isxdigit(zUri[iIn]) && sqlite3Isxdigit(zUri[iIn])
&& sqlite3Isxdigit(zUri[iIn+1]) && sqlite3Isxdigit(zUri[iIn+1])
@@ -1888,10 +1889,10 @@ int sqlite3ParseUri(
** case we ignore all text in the remainder of the path, name or ** case we ignore all text in the remainder of the path, name or
** value currently being parsed. So ignore the current character ** value currently being parsed. So ignore the current character
** and skip to the next "?", "=" or "&", as appropriate. */ ** and skip to the next "?", "=" or "&", as appropriate. */
while( zUri[iIn] && zUri[iIn]!='#' while( (c = zUri[iIn])!=0 && c!='#'
&& (eState!=0 || zUri[iIn]!='?') && (eState!=0 || c!='?')
&& (eState!=1 || (zUri[iIn]!='=' && zUri[iIn]!='&')) && (eState!=1 || (c!='=' && c!='&'))
&& (eState!=2 || zUri[iIn]!='&') && (eState!=2 || c!='&')
){ ){
iIn++; iIn++;
} }
@@ -1983,6 +1984,8 @@ int sqlite3ParseUri(
goto parse_uri_out; goto parse_uri_out;
} }
if( mode>limit ){ if( mode>limit ){
*pzErrMsg = sqlite3_mprintf("%s mode not allowed: %s",
zModeType, zVal);
rc = SQLITE_PERM; rc = SQLITE_PERM;
goto parse_uri_out; goto parse_uri_out;
} }