Fix a missing zero-terminator on a string when processing

JSON aggregates into JSONB.

FossilOrigin-Name: fb81d570a3d9b8f55e9f278d5240605c5d0f3c5abde51550797999d03cf193a7
This commit is contained in:
drh 2023-10-11 13:19:37 +00:00
parent 2b7a1f5926
commit 86db4555ca
3 changed files with 16 additions and 7 deletions

View File

@ -1,5 +1,5 @@
C Fix\san\sissue\sthat\scan\sarise\swhen\sprocessing\scorrupt\sJSONB.
D 2023-10-11T12:44:17.002
C Fix\sa\smissing\szero-terminator\son\sa\sstring\swhen\sprocessing\nJSON\saggregates\sinto\sJSONB.
D 2023-10-11T13:19:37.907
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@ -674,7 +674,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 d2b028758bc86b4ea3bde09effd05460945ee79286f1147bd90b233cdaec440b
F src/json.c 6c394327f052d3be3c4c2d21d9b8874320992e7d6f8b806db73c5b834e71c7bd
F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa
F src/loadext.c 98cfba10989b3da6f1807ad42444017742db7f100a54f1032af7a8b1295912c0
F src/main.c 618aeb399e993cf561864f4b0cf6a331ee4f355cf663635f8d9da3193a46aa40
@ -2129,8 +2129,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 0fbda92bb0eeb40f95c83f717e4e8f5bff1ac82f1c899e9f6d400d67df67214e
R d76df8cb5e7347049ec337effa1f07fd
P e50045c22296be84c6bea82bb8b310f07bca820c84d4a7349b16da0cf5d2657c
R 8c875e6758b9f56e162d8b6b955529e9
U drh
Z 97ae228d7814f1fddc06d3cfd13d0a3f
Z d51d36a4b4191be2ce04b67a30dc0525
# Remove this line to create a well-formed Fossil manifest.

View File

@ -1 +1 @@
e50045c22296be84c6bea82bb8b310f07bca820c84d4a7349b16da0cf5d2657c
fb81d570a3d9b8f55e9f278d5240605c5d0f3c5abde51550797999d03cf193a7

View File

@ -486,6 +486,14 @@ static void jsonAppendChar(JsonString *p, char c){
}
}
/* Make sure there is a zero terminator on p->zBuf[]
*/
static void jsonStringTerminate(JsonString *p){
if( p->nUsed<p->nAlloc || jsonStringGrow(p,1) ){
p->zBuf[p->nUsed] = 0;
}
}
/* Try to force the string to be a zero-terminated RCStr string.
**
** Return true on success. Return false if an OOM prevents this
@ -3210,6 +3218,7 @@ static int jsonConvertTextToBlob(
static void jsonReturnStringAsBlob(JsonString *pStr){
JsonParse px;
memset(&px, 0, sizeof(px));
jsonStringTerminate(pStr);
px.zJson = pStr->zBuf;
px.nJson = pStr->nUsed;
(void)jsonXlateTextToBlob(&px, 0);