aboutsummaryrefslogtreecommitdiff
path: root/src/json.c
diff options
context:
space:
mode:
authordrh <>2023-11-21 19:05:22 +0000
committerdrh <>2023-11-21 19:05:22 +0000
commite1df37b9477da7d0345c3faac628d5e7603bde7d (patch)
tree41cba54e0a5e5657299218beae7bcd14358db53f /src/json.c
parent664fe310b5749c18fceb7c249f45b2b8cfc7dc21 (diff)
downloadsqlite-e1df37b9477da7d0345c3faac628d5e7603bde7d.tar.gz
sqlite-e1df37b9477da7d0345c3faac628d5e7603bde7d.zip
Correct blob-to-text rendering in some corner cases.
FossilOrigin-Name: 7822e0e59f9b611fe6289cc762b0aff61f9b87c3a82c60de110f447589a2c125
Diffstat (limited to 'src/json.c')
-rw-r--r--src/json.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/json.c b/src/json.c
index 69950766d..199bc5e18 100644
--- a/src/json.c
+++ b/src/json.c
@@ -3372,6 +3372,7 @@ static u32 jsonXlateBlobToText(
u32 k = 2;
sqlite3_uint64 u = 0;
const char *zIn = (const char*)&pParse->aBlob[i+n];
+ int bOverflow = 0;
if( zIn[0]=='-' ){
jsonAppendChar(pOut, '-');
k++;
@@ -3382,11 +3383,13 @@ static u32 jsonXlateBlobToText(
if( !sqlite3Isxdigit(zIn[k]) ){
pOut->eErr |= JSTRING_MALFORMED;
break;
+ }else if( (u>>60)!=0 ){
+ bOverflow = 1;
}else{
u = u*16 + sqlite3HexToInt(zIn[k]);
}
}
- jsonPrintf(100,pOut,"%llu",u);
+ jsonPrintf(100,pOut,bOverflow?"9.0e999":"%llu", u);
break;
}
case JSONB_FLOAT5: { /* Float literal missing digits beside "." */
@@ -3519,6 +3522,7 @@ static u32 jsonXlateBlobToText(
j = jsonXlateBlobToText(pParse, j, pOut);
jsonAppendChar(pOut, (x++ & 1) ? ',' : ':');
}
+ if( x & 1 ) pOut->eErr |= JSTRING_MALFORMED;
if( sz>0 ) pOut->nUsed--;
jsonAppendChar(pOut, '}');
break;