-C Limit\sJSONB\srecursion\sdepth\sin\sthe\sjson_patch()\sfunction.
-D 2026-03-24T12:39:05.703
+C Prevent\soverly\slong\sJSON\spaths\sfrom\susing\stoo\smuch\sstack\sspace.
+D 2026-03-24T19:26:05.509
F .fossil-settings/binary-glob 61195414528fb3ea9693577e1980230d78a1f8b0a54c78cf1b9b24d0a409ed6a x
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F src/hwtime.h 21c2cf1f736e7b97502c3674d0c386db3f06870d6f10d0cf8174e2a4b8cb726e
F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71
F src/insert.c dfd311b0ac2d4f6359e62013db67799757f4d2cc56cca5c10f4888acfbbfa3fd
-F src/json.c 3d790a2822cf3938d808dd4c82713e640f2fc410504b0f853dc32b8fa585bad4
+F src/json.c 5027b856cd9b621dc9ba66b211e21a440ccdc63cefdefb44c51e7d3ac550d1a4
F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa
F src/loadext.c 187929338d21f43cbdea359a3c1ec61294f39b7f9032e824c1dbb79f9994c838
F src/main.c 31a13302193fbd51279c7e69cdfa0320d0de7629f9151e0964c1d320e8bdd7a4
F tool/warnings.sh a554d13f6e5cf3760f041b87939e3d616ec6961859c3245e8ef701d1eafc2ca2
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
F tool/winmain.c 00c8fb88e365c9017db14c73d3c78af62194d9644feaf60e220ab0f411f3604c
-P 82036fafa175e798fd32b3dc4ad043fc2bbe2bb2af17781f12dcb4d23a233865
-R cfe70b6eb98b5198569bd46361e5c403
+P f8659b700c0088abe19ce65fec032c1005a1f750566488f4578256d41558770c
+R 758e0af8a0882e7e9923c695c5403a23
U drh
-Z 24e4693854a4d68b165699d3ce0f66fc
+Z 1af8ca46b9aa6ac26d04c5ed95b2b6cf
# Remove this line to create a well-formed Fossil manifest.
#define JSON_LOOKUP_ERROR 0xffffffff
#define JSON_LOOKUP_NOTFOUND 0xfffffffe
#define JSON_LOOKUP_NOTARRAY 0xfffffffd
-#define JSON_LOOKUP_PATHERROR 0xfffffffc
+#define JSON_LOOKUP_TOODEEP 0xfffffffc
+#define JSON_LOOKUP_PATHERROR 0xfffffffb
#define JSON_LOOKUP_ISERROR(x) ((x)>=JSON_LOOKUP_PATHERROR)
/* Forward declaration */
pIns->eEdit = pParse->eEdit;
pIns->nIns = pParse->nIns;
pIns->aIns = pParse->aIns;
+ pIns->iDepth = pParse->iDepth+1;
+ if( pIns->iDepth >= JSON_MAX_DEPTH ){
+ return JSON_LOOKUP_TOODEEP;
+ }
rc = jsonLookupStep(pIns, 0, zTail, 0);
+ pParse->iDepth--;
pParse->oom |= pIns->oom;
}
return rc; /* Error code only */
n = jsonbPayloadSize(pParse, v, &sz);
if( n==0 || v+n+sz>iEnd ) return JSON_LOOKUP_ERROR;
assert( j>0 );
+ if( ++pParse->iDepth >= JSON_MAX_DEPTH ){
+ return JSON_LOOKUP_TOODEEP;
+ }
rc = jsonLookupStep(pParse, v, &zPath[i], j);
+ pParse->iDepth--;
if( pParse->delta ) jsonAfterEditSizeAdjust(pParse, iRoot);
return rc;
}
iEnd = j+sz;
while( j<iEnd ){
if( kk==0 ){
+ if( ++pParse->iDepth >= JSON_MAX_DEPTH ){
+ return JSON_LOOKUP_TOODEEP;
+ }
rc = jsonLookupStep(pParse, j, &zPath[i+1], 0);
+ pParse->iDepth--;
if( pParse->delta ) jsonAfterEditSizeAdjust(pParse, iRoot);
return rc;
}
**
** The specifics of the error are determined by the rc argument.
**
-** rc error
-** ----------------- ----------------
+** rc error
+** ----------------- ----------------------
** JSON_LOOKUP_ARRAY "not an array"
+** JSON_LOOKUP_TOODEEP "JSON nested too deep"
** JSON_LOOKUP_ERROR "malformed JSON"
** otherwise... "bad JSON path"
**
zMsg = sqlite3_mprintf("not an array element: %Q", zPath);
}else if( rc==(int)JSON_LOOKUP_ERROR ){
zMsg = sqlite3_mprintf("malformed JSON");
+ }else if( rc==(int)JSON_LOOKUP_TOODEEP ){
+ zMsg = sqlite3_mprintf("JSON path too deep");
}else{
zMsg = sqlite3_mprintf("bad JSON path: %Q", zPath);
}
p->nIns = ax.nBlob;
p->aIns = ax.aBlob;
p->delta = 0;
+ p->iDepth = 0;
rc = jsonLookupStep(p, 0, zPath+1, 0);
}
jsonParseReset(&ax);