]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Detect and respond to an OOM on the jsonStringTerminate() call of
authordrh <>
Wed, 7 Feb 2024 14:05:38 +0000 (14:05 +0000)
committerdrh <>
Wed, 7 Feb 2024 14:05:38 +0000 (14:05 +0000)
jsonReturnStringAsBlob() routine.

FossilOrigin-Name: 881f814c09b6896a448a2360b0b43dc99592ea3a1d72ac359770cbb0a2c7d38a

manifest
manifest.uuid
src/json.c

index e10d3001290606cc5070c25ca59105782f57f88d..33b0966c6b7e0d5ea3a525c95264e8510801c8c3 100644 (file)
--- a/manifest
+++ b/manifest
@@ -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.
index 278abcfe7294a7260735d3646f18c18c82678f4a..a559efd0b5246ae285121d0733e7f551cd0545ac 100644 (file)
@@ -1 +1 @@
-6a2b3266c586d12b51e11fe63cda5881be9373207aa16671ab77f547830eb790
\ No newline at end of file
+881f814c09b6896a448a2360b0b43dc99592ea3a1d72ac359770cbb0a2c7d38a
\ No newline at end of file
index 1a4ce3af195ab8238fd3d44ce3030f38a0886d3c..3aa4b4e500d8733a089cebba206625d41ecdf411 100644 (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);