Improvements to JSONB validation - catch more cases where the input does
not conform to spec. FossilOrigin-Name: be1864eac4eb75cc30bf98f73092c8608467f4bd956240df6a0cbea9f1e09e85
This commit is contained in:
parent
cc1a39fd24
commit
87399a56db
12
manifest
12
manifest
@ -1,5 +1,5 @@
|
||||
C Validity\schecking\sof\stext\snodes\sin\sJSONB.
|
||||
D 2023-12-12T02:31:12.655
|
||||
C Improvements\sto\sJSONB\svalidation\s-\scatch\smore\scases\swhere\sthe\sinput\sdoes\nnot\sconform\sto\sspec.
|
||||
D 2023-12-12T14:33:52.419
|
||||
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
||||
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
||||
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
|
||||
@ -696,7 +696,7 @@ F src/hash.h 3340ab6e1d13e725571d7cee6d3e3135f0779a7d8e76a9ce0a85971fa3953c51
|
||||
F src/hwtime.h f9c2dfb84dce7acf95ce6d289e46f5f9d3d1afd328e53da8f8e9008e3b3caae6
|
||||
F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71
|
||||
F src/insert.c 3f0a94082d978bbdd33c38fefea15346c6c6bffb70bc645a71dc0f1f87dd3276
|
||||
F src/json.c 34f829db190ae485926855da651d349eedb35fa56010266e14c0b094f536c9f5
|
||||
F src/json.c 6fc223a6cf1f475dfe72376018615ed85a1415b57121571ad65747f8b845b57f
|
||||
F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa
|
||||
F src/loadext.c 7432c944ff197046d67a1207790a1b13eec4548c85a9457eb0896bb3641dfb36
|
||||
F src/main.c ce714ee501122c76eb2e69b292bebe443aba611fc3b88e6786eb910285515fe4
|
||||
@ -2153,8 +2153,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
|
||||
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
||||
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
||||
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
||||
P 80d5d94dff6a2d2557039be3d7d47c1a6003c4b98defe0bd411acfeb963ad5dd
|
||||
R 8ac47232b4f02631d44b831db0790bc1
|
||||
P fa5160687c2f970d407e8af73c246f7cd806bb4ce35f29a79ac534a8646a6c8e
|
||||
R 06eab0897027e01e7643ca8237160284
|
||||
U drh
|
||||
Z 8178cefe916c4486a65df71a751de097
|
||||
Z fe2966c205a693292efc9fe6aaf9e427
|
||||
# Remove this line to create a well-formed Fossil manifest.
|
||||
|
@ -1 +1 @@
|
||||
fa5160687c2f970d407e8af73c246f7cd806bb4ce35f29a79ac534a8646a6c8e
|
||||
be1864eac4eb75cc30bf98f73092c8608467f4bd956240df6a0cbea9f1e09e85
|
12
src/json.c
12
src/json.c
@ -1265,9 +1265,6 @@ static u32 jsonbValidityCheck(
|
||||
case JSONB_FALSE: {
|
||||
return n+sz==1 ? 0 : i+1;
|
||||
}
|
||||
default: {
|
||||
return i+1;
|
||||
}
|
||||
case JSONB_INT: {
|
||||
if( sz<1 ) return i+1;
|
||||
j = i+n;
|
||||
@ -1316,6 +1313,7 @@ static u32 jsonbValidityCheck(
|
||||
if( sz<3 ) return i+1;
|
||||
}
|
||||
if( z[j]=='.' ){
|
||||
if( x==JSONB_FLOAT ) return j+1;
|
||||
if( !sqlite3Isdigit(z[j+1]) ) return j+1;
|
||||
j += 2;
|
||||
seen = 1;
|
||||
@ -1327,7 +1325,7 @@ static u32 jsonbValidityCheck(
|
||||
for(; j<k; j++){
|
||||
if( sqlite3Isdigit(z[j]) ) continue;
|
||||
if( z[j]=='.' ){
|
||||
if( seen>0 ) return i+1;
|
||||
if( seen>0 ) return j+1;
|
||||
if( x==JSONB_FLOAT && (j==k-1 || !sqlite3Isdigit(z[j+1])) ){
|
||||
return j+1;
|
||||
}
|
||||
@ -1346,6 +1344,7 @@ static u32 jsonbValidityCheck(
|
||||
}
|
||||
return j+1;
|
||||
}
|
||||
if( seen==0 ) return i+1;
|
||||
return 0;
|
||||
}
|
||||
case JSONB_TEXT: {
|
||||
@ -1429,6 +1428,9 @@ static u32 jsonbValidityCheck(
|
||||
if( (cnt & 1)!=0 ) return j+1;
|
||||
return 0;
|
||||
}
|
||||
default: {
|
||||
return i+1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -4234,7 +4236,7 @@ static void jsonErrorFunc(
|
||||
if( jsonFuncArgMightBeBinary(argv[0]) ){
|
||||
s.aBlob = (u8*)sqlite3_value_blob(argv[0]);
|
||||
s.nBlob = sqlite3_value_bytes(argv[0]);
|
||||
iErrPos = (i64)jsonbValidityCheck(&s, 0, s.nBlob, 0);
|
||||
iErrPos = (i64)jsonbValidityCheck(&s, 0, s.nBlob, 1);
|
||||
}else{
|
||||
s.zJson = (char*)sqlite3_value_text(argv[0]);
|
||||
if( s.zJson==0 ) return; /* NULL input or OOM */
|
||||
|
Loading…
Reference in New Issue
Block a user