From: drh Date: Wed, 23 Sep 2015 01:10:29 +0000 (+0000) Subject: Do not allow a comma at the end of a JSON array or object. X-Git-Tag: version-3.9.0~74 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f27cd1f3aa7852d29a27eac7228769ce93b80635;p=thirdparty%2Fsqlite.git Do not allow a comma at the end of a JSON array or object. FossilOrigin-Name: 7c7a3f3e9bc2f7a7334d8d6eae183d83f22097be --- diff --git a/ext/misc/json1.c b/ext/misc/json1.c index db8d09b9bc..3dd831f9c5 100644 --- a/ext/misc/json1.c +++ b/ext/misc/json1.c @@ -606,7 +606,7 @@ static int jsonParseValue(JsonParse *pParse, u32 i){ while( safe_isspace(pParse->zJson[j]) ){ j++; } x = jsonParseValue(pParse, j); if( x<0 ){ - if( x==(-2) ) return j+1; + if( x==(-2) && pParse->nNode==(u32)iThis+1 ) return j+1; return -1; } if( pParse->oom ) return -1; @@ -636,7 +636,7 @@ static int jsonParseValue(JsonParse *pParse, u32 i){ while( safe_isspace(pParse->zJson[j]) ){ j++; } x = jsonParseValue(pParse, j); if( x<0 ){ - if( x==(-3) ) return j+1; + if( x==(-3) && pParse->nNode==(u32)iThis+1 ) return j+1; return -1; } j = x; diff --git a/manifest b/manifest index 43c8af7630..d85cf93eac 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\s--export-sql\sand\s--export-db\soptions\sto\sthe\sfuzzcheck\sutility\sprogram. -D 2015-09-22T18:51:17.054 +C Do\snot\sallow\sa\scomma\sat\sthe\send\sof\sa\sJSON\sarray\sor\sobject. +D 2015-09-23T01:10:29.723 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 2047811644c5bac91ccdfc2720e49b60965a63a7 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -195,7 +195,7 @@ F ext/misc/eval.c f971962e92ebb8b0a4e6b62949463ee454d88fa2 F ext/misc/fileio.c d4171c815d6543a9edef8308aab2951413cd8d0f F ext/misc/fuzzer.c 4c84635c71c26cfa7c2e5848cf49fe2d2cfcd767 F ext/misc/ieee754.c b0362167289170627659e84173f5d2e8fee8566e -F ext/misc/json1.c 8eefcbdc172e9eff3c613016260c2d82893c12f2 +F ext/misc/json1.c 7659013d8d84a263ae60cd01cdc25d3596cf5063 F ext/misc/nextchar.c 35c8b8baacb96d92abbb34a83a997b797075b342 F ext/misc/percentile.c bcbee3c061b884eccb80e21651daaae8e1e43c63 F ext/misc/regexp.c af92cdaa5058fcec1451e49becc7ba44dba023dc @@ -815,7 +815,7 @@ F test/journal3.test ff8af941f9e06161d3db1b46bb9f965ff0e7f307 F test/jrnlmode.test 7864d59cf7f6e552b9b99ba0f38acd167edc10fa F test/jrnlmode2.test 81610545a4e6ed239ea8fa661891893385e23a1d F test/jrnlmode3.test 556b447a05be0e0963f4311e95ab1632b11c9eaa -F test/json101.test bfc81e4bdb412a1659160a4284448bd212ba6df1 +F test/json101.test 07f0d847d943bf5ad6e8fb60699a7f4c57317321 F test/json102.test 796b1c59894c6e0f38fc1a3acb0e690573b952a3 F test/keyword1.test 37ef6bba5d2ed5b07ecdd6810571de2956599dff F test/lastinsert.test 42e948fd6442f07d60acbd15d33fb86473e0ef63 @@ -1387,7 +1387,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P b6ae61fe3b3de3aa296b3e56cd2ec425a5141c73 -R 67147fe50bd6bcd304574882b2915749 +P 760af4455115669b934c3115d45cffe89c085faf +R 6b381fff3f89ce025323ce04ac2d6070 U drh -Z f2fe8ea148ad21aa4f5e236ec8c81968 +Z 8b081193fe15e32207901b3f263d0f6d diff --git a/manifest.uuid b/manifest.uuid index 36534fefd4..5101911d89 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -760af4455115669b934c3115d45cffe89c085faf \ No newline at end of file +7c7a3f3e9bc2f7a7334d8d6eae183d83f22097be \ No newline at end of file diff --git a/test/json101.test b/test/json101.test index 4f1b7056d9..22bbb4d5e4 100644 --- a/test/json101.test +++ b/test/json101.test @@ -305,6 +305,18 @@ do_execsql_test json-5.8 { WHERE jx.value<>jx.atom AND type NOT IN ('array','object'); } {} +do_execsql_test json-6.1 { + SELECT json_valid('{"a":55,"b":72,}'); +} {0} +do_execsql_test json-6.2 { + SELECT json_valid('{"a":55,"b":72}'); +} {1} +do_execsql_test json-6.3 { + SELECT json_valid('["a",55,"b",72,]'); +} {0} +do_execsql_test json-6.4 { + SELECT json_valid('["a",55,"b",72]'); +} {1} finish_test