Detect and respond to an OOM on the jsonStringTerminate() call of

jsonReturnStringAsBlob() routine.

FossilOrigin-Name: 881f814c09b6896a448a2360b0b43dc99592ea3a1d72ac359770cbb0a2c7d38a
This commit is contained in:
drh 2024-02-07 14:05:38 +00:00
parent 8babc01892
commit 71cdea8f5f
3 changed files with 12 additions and 7 deletions

View File

@ -1,5 +1,5 @@
C Slight\schange\sto\sOOM\shandling\sin\sJSON\sto\scatch\sa\scorner\scase\sfound\sby\ndbsqlfuzz.
D 2024-02-06T18:33:01.726
C Detect\sand\srespond\sto\san\sOOM\son\sthe\sjsonStringTerminate()\scall\sof\njsonReturnStringAsBlob()\sroutine.
D 2024-02-07T14:05:38.048
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@ -699,7 +699,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 0c98979fac084ea5055738fb3467cd431543aaa94acf374d412cac4b89b1acbf
F src/json.c a0346bef35804e468b9ea0c34a08960f4f543a61683182a3ec1fe30df3b98140
F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa
F src/loadext.c 7432c944ff197046d67a1207790a1b13eec4548c85a9457eb0896bb3641dfb36
F src/main.c 438b95162acfa17b7d218f586f5bde11d6ae82bcf030c9611fc537556870ad6b
@ -2162,8 +2162,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 ae7505fa5e112f39a329befb35eff6ddf46a53f5deb610906550bf67f56fc157
R bb17ade8dce33fbd8ddcb5bbd3943bbd
P 6a2b3266c586d12b51e11fe63cda5881be9373207aa16671ab77f547830eb790
R f921e7ed48eb9865e88c87b2fd0e4d7e
U drh
Z 8a6aaa8f9831a5f71eadc202a02ba963
Z 643b9a87bc06a07fb41a72f9a7566e9f
# Remove this line to create a well-formed Fossil manifest.

View File

@ -1 +1 @@
6a2b3266c586d12b51e11fe63cda5881be9373207aa16671ab77f547830eb790
881f814c09b6896a448a2360b0b43dc99592ea3a1d72ac359770cbb0a2c7d38a

View File

@ -1623,6 +1623,7 @@ json_parse_restart:
case '[': {
/* Parse array */
iThis = pParse->nBlob;
assert( i<=pParse->nJson );
jsonBlobAppendNode(pParse, JSONB_ARRAY, pParse->nJson - i, 0);
iStart = pParse->nBlob;
if( pParse->oom ) return -1;
@ -2027,6 +2028,10 @@ static void jsonReturnStringAsBlob(JsonString *pStr){
JsonParse px;
memset(&px, 0, sizeof(px));
jsonStringTerminate(pStr);
if( pStr->eErr ){
sqlite3_result_error_nomem(pStr->pCtx);
return;
}
px.zJson = pStr->zBuf;
px.nJson = pStr->nUsed;
px.db = sqlite3_context_db_handle(pStr->pCtx);