aboutsummaryrefslogtreecommitdiff
path: root/src/json.c
diff options
context:
space:
mode:
authordrh <>2023-10-11 12:21:29 +0000
committerdrh <>2023-10-11 12:21:29 +0000
commit33b56217cb7f1ced7553449daccc032230a8b53a (patch)
tree3890d5e480efa72214247296a638d13bbb17311f /src/json.c
parent2a96a1584d58a9959e1f4867de25682793637837 (diff)
downloadsqlite-33b56217cb7f1ced7553449daccc032230a8b53a.tar.gz
sqlite-33b56217cb7f1ced7553449daccc032230a8b53a.zip
Improved robustness against corrupt JSONB.
FossilOrigin-Name: 0fbda92bb0eeb40f95c83f717e4e8f5bff1ac82f1c899e9f6d400d67df67214e
Diffstat (limited to 'src/json.c')
-rw-r--r--src/json.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/src/json.c b/src/json.c
index 0ddc9c498..ff735f36f 100644
--- a/src/json.c
+++ b/src/json.c
@@ -981,7 +981,7 @@ static void jsonXlateNodeToText(
u32 j = 1;
jsonAppendChar(pOut, '{');
for(;;){
- while( j<=pNode->n ){
+ while( j<pNode->n ){
if( (pNode[j+1].jnFlags & JNODE_REMOVE)==0 || pParse->useMod==0 ){
jsonAppendSeparator(pOut);
jsonXlateNodeToText(pParse, &pNode[j], pOut);
@@ -1054,7 +1054,7 @@ static void jsonReturnNodeAsJson(
** character: 0..9a..fA..F
*/
static u8 jsonHexToInt(int h){
- assert( (h>='0' && h<='9') || (h>='a' && h<='f') || (h>='A' && h<='F') );
+ if( !sqlite3Isxdigit(h) ) return 0;
#ifdef SQLITE_EBCDIC
h += 9*(1&~(h>>4));
#else
@@ -1068,10 +1068,6 @@ static u8 jsonHexToInt(int h){
*/
static u32 jsonHexToInt4(const char *z){
u32 v;
- assert( sqlite3Isxdigit(z[0]) );
- assert( sqlite3Isxdigit(z[1]) );
- assert( sqlite3Isxdigit(z[2]) );
- assert( sqlite3Isxdigit(z[3]) );
v = (jsonHexToInt(z[0])<<12)
+ (jsonHexToInt(z[1])<<8)
+ (jsonHexToInt(z[2])<<4)