Better error detection when doing a lookup on a JSONB.

FossilOrigin-Name: 6e8e0eedbf06e175af6ef230f1ce9a5ad84698b1c6dcd2794d878c746e7b6be4
This commit is contained in:
drh 2023-10-05 23:05:35 +00:00
parent f7af8f3270
commit 27401d38d8
3 changed files with 10 additions and 7 deletions

View File

@ -1,5 +1,5 @@
C Improvements\sto\scomments.\s\sNo\schanges\sto\scode. C Better\serror\sdetection\swhen\sdoing\sa\slookup\son\sa\sJSONB.
D 2023-10-05T22:52:43.004 D 2023-10-05T23:05:35.100
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@ -670,7 +670,7 @@ F src/hash.h 3340ab6e1d13e725571d7cee6d3e3135f0779a7d8e76a9ce0a85971fa3953c51
F src/hwtime.h f9c2dfb84dce7acf95ce6d289e46f5f9d3d1afd328e53da8f8e9008e3b3caae6 F src/hwtime.h f9c2dfb84dce7acf95ce6d289e46f5f9d3d1afd328e53da8f8e9008e3b3caae6
F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71 F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71
F src/insert.c 3f0a94082d978bbdd33c38fefea15346c6c6bffb70bc645a71dc0f1f87dd3276 F src/insert.c 3f0a94082d978bbdd33c38fefea15346c6c6bffb70bc645a71dc0f1f87dd3276
F src/json.c a51a9dd785d3d65f7b4ffc3827610571efae82c5f7469ff8bc9b973de4b43245 F src/json.c 1b3349c49b363c654b76f5f9b45c4172d13955679fd4a242b3d92c879f95294c
F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa
F src/loadext.c 98cfba10989b3da6f1807ad42444017742db7f100a54f1032af7a8b1295912c0 F src/loadext.c 98cfba10989b3da6f1807ad42444017742db7f100a54f1032af7a8b1295912c0
F src/main.c 618aeb399e993cf561864f4b0cf6a331ee4f355cf663635f8d9da3193a46aa40 F src/main.c 618aeb399e993cf561864f4b0cf6a331ee4f355cf663635f8d9da3193a46aa40
@ -2124,8 +2124,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
P 0f75199160e48fa8c44f986f1af777adf19e40fbd114a6f58e24d5e6dede779d P ac74d7877685006e43684edd6a2d22be8c9857f9f9eb52fc5b3c182d5e2fdb8d
R 61adb43472fe06712b001bc8a8daf5aa R 01e239b11851146ca21382a5317a867b
U drh U drh
Z b88584b3539f893217397c49059fc0f7 Z 51245adc64c2e53d6bd1f03542705249
# Remove this line to create a well-formed Fossil manifest. # Remove this line to create a well-formed Fossil manifest.

View File

@ -1 +1 @@
ac74d7877685006e43684edd6a2d22be8c9857f9f9eb52fc5b3c182d5e2fdb8d 6e8e0eedbf06e175af6ef230f1ce9a5ad84698b1c6dcd2794d878c746e7b6be4

View File

@ -3720,6 +3720,7 @@ static u32 jsonLookupBlobStep(
x = pParse->aBlob[j] & 0x0f; x = pParse->aBlob[j] & 0x0f;
if( x<JSONB_TEXT || x>JSONB_TEXTRAW ) return JSON_BLOB_ERROR; if( x<JSONB_TEXT || x>JSONB_TEXTRAW ) return JSON_BLOB_ERROR;
n = jsonbPayloadSize(pParse, j, &sz); n = jsonbPayloadSize(pParse, j, &sz);
if( n==0 ) return JSON_BLOB_ERROR;
k = j+n; k = j+n;
if( k+sz>=iEnd ) return JSON_BLOB_ERROR; if( k+sz>=iEnd ) return JSON_BLOB_ERROR;
if( sz==nKey && memcmp(&pParse->aBlob[k], zKey, nKey)==0 ){ if( sz==nKey && memcmp(&pParse->aBlob[k], zKey, nKey)==0 ){
@ -3732,6 +3733,7 @@ static u32 jsonLookupBlobStep(
j = k+sz; j = k+sz;
if( ((pParse->aBlob[j])&0x0f)>JSONB_OBJECT ) return JSON_BLOB_ERROR; if( ((pParse->aBlob[j])&0x0f)>JSONB_OBJECT ) return JSON_BLOB_ERROR;
n = jsonbPayloadSize(pParse, j, &sz); n = jsonbPayloadSize(pParse, j, &sz);
if( n==0 ) return JSON_BLOB_ERROR;
j += n+sz; j += n+sz;
} }
if( j>iEnd ) return JSON_BLOB_ERROR; if( j>iEnd ) return JSON_BLOB_ERROR;
@ -3776,6 +3778,7 @@ static u32 jsonLookupBlobStep(
} }
k--; k--;
n = jsonbPayloadSize(pParse, j, &sz); n = jsonbPayloadSize(pParse, j, &sz);
if( n==0 ) return JSON_BLOB_ERROR;
j += n+sz; j += n+sz;
} }
if( j>iEnd ) return JSON_BLOB_ERROR; if( j>iEnd ) return JSON_BLOB_ERROR;