With the -DSQLITE_ENABLE_JSON_NAN_INF compile-time option, non-standard
JSON numeric values "Inf", "Infinity", "-Inf", "-Infinity", "NaN", "QNaN", and "SNaN" are all accepted. SQLite should never generate these values, but it will accept that with the appropriate compile-time option. FossilOrigin-Name: 0a050e9013331595e13ca9f859180057b59291c70a6cedb6230eefb25956df9e
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
C Earlier\sdetection\sof\scorruption\sin\ssqlite3BtreeDelete().\ndbsqlfuzz\sa4c48c291d6e40157a1b749a05eaa7c7faf5a625.
|
||||
D 2023-04-02T16:43:20.854
|
||||
C With\sthe\s-DSQLITE_ENABLE_JSON_NAN_INF\scompile-time\soption,\snon-standard\nJSON\snumeric\svalues\s"Inf",\s"Infinity",\s"-Inf",\s"-Infinity",\s"NaN",\s"QNaN",\nand\s"SNaN"\sare\sall\saccepted.\s\sSQLite\sshould\snever\sgenerate\sthese\svalues,\nbut\sit\swill\saccept\sthat\swith\sthe\sappropriate\scompile-time\soption.
|
||||
D 2023-04-02T20:56:29.250
|
||||
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
||||
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
||||
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
|
||||
@@ -585,7 +585,7 @@ F src/hash.h 3340ab6e1d13e725571d7cee6d3e3135f0779a7d8e76a9ce0a85971fa3953c51
|
||||
F src/hwtime.h b638809e083b601b618df877b2e89cb87c2a47a01f4def10be4c4ebb54664ac7
|
||||
F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71
|
||||
F src/insert.c a8de1db43335fc4946370a7a7e47d89975ad678ddb15078a150e993ba2fb37d4
|
||||
F src/json.c 9e3a6acf9e4fa8bb6c84a38538ed9c2f9ad09f106910ef0e9cc68e19c8dc4fc8
|
||||
F src/json.c edae65fe1f66ce8b1e7fa6eb036a3d8cf525dacd91d58f12068e80a81ac34f61
|
||||
F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa
|
||||
F src/loadext.c be5af440f3192c58681b5d43167dbca3ccbfce394d89faa22378a14264781136
|
||||
F src/main.c 09bc5191f75dc48fc4dfddda143cb864c0c3dbc3297eb9a9c8e01fea58ff847d
|
||||
@@ -2052,8 +2052,9 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
|
||||
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
||||
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
||||
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
||||
P ec1ddbce7db270afc25f71546fa745935ad74bc72920fccfcb37e98649612bf2
|
||||
R 1f7f7780d232aaca9814c0eee95933c1
|
||||
P 978dc71c388b37740da38c310674315c7d7fe814d1daa16a146b4df71385d1e1 dbc99662087b63c9ed5b398535a6091fc2c5e507907dd1fcb7ad0b6ab3f17144
|
||||
R 0c80a0a9d7056c4e9cc79fd3f48ab255
|
||||
T +closed dbc99662087b63c9ed5b398535a6091fc2c5e507907dd1fcb7ad0b6ab3f17144
|
||||
U drh
|
||||
Z 4959631f3771aa98a65ccf057f0978b9
|
||||
Z ff807b459bbce1f6e27ef0b5e65a972d
|
||||
# Remove this line to create a well-formed Fossil manifest.
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
978dc71c388b37740da38c310674315c7d7fe814d1daa16a146b4df71385d1e1
|
||||
0a050e9013331595e13ca9f859180057b59291c70a6cedb6230eefb25956df9e
|
||||
+53
@@ -757,6 +757,27 @@ static int jsonIs4Hex(const char *z){
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifdef SQLITE_ENABLE_JSON_NAN_INF
|
||||
/*
|
||||
** Extra floating-point literals to allow in JSON.
|
||||
*/
|
||||
static const struct NanInfName {
|
||||
char c1;
|
||||
char c2;
|
||||
char n;
|
||||
char eType;
|
||||
char nRepl;
|
||||
char *zMatch;
|
||||
char *zRepl;
|
||||
} aNanInfName[] = {
|
||||
{ 'i', 'I', 3, JSON_REAL, 7, "inf", "9.0e999" },
|
||||
{ 'i', 'I', 8, JSON_REAL, 7, "infinity", "9.0e999" },
|
||||
{ 'n', 'N', 3, JSON_NULL, 4, "NaN", "null" },
|
||||
{ 'q', 'Q', 4, JSON_NULL, 4, "QNaN", "null" },
|
||||
{ 's', 'S', 4, JSON_NULL, 4, "SNaN", "null" },
|
||||
};
|
||||
#endif /* SQLITE_ENABLE_JSON_NAN_INF */
|
||||
|
||||
/*
|
||||
** Parse a single JSON value which begins at pParse->zJson[i]. Return the
|
||||
** index of the first character past the end of the value parsed.
|
||||
@@ -902,6 +923,24 @@ static int jsonParseValue(JsonParse *pParse, u32 i){
|
||||
if( c<'0' || c>'9' ) return -1;
|
||||
continue;
|
||||
}
|
||||
#ifdef SQLITE_ENABLE_JSON_NAN_INF
|
||||
/* Non-standard JSON: Allow "-Inf" (in any case)
|
||||
** to be understood as floating point literals. */
|
||||
if( (c=='i' || c=='I')
|
||||
&& j==i+1
|
||||
&& z[i]=='-'
|
||||
&& sqlite3StrNICmp(&z[j], "inf",3)==0
|
||||
){
|
||||
if( !sqlite3Isalnum(z[j+3]) ){
|
||||
jsonParseAddNode(pParse, JSON_REAL, 8, "-9.0e999");
|
||||
return i+4;
|
||||
}else if( (sqlite3StrNICmp(&z[j],"infinity",8)==0 &&
|
||||
!sqlite3Isalnum(z[j+8])) ){
|
||||
jsonParseAddNode(pParse, JSON_REAL, 8, "-9.0e999");
|
||||
return i+9;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
if( z[j-1]<'0' ) return -1;
|
||||
@@ -915,6 +954,20 @@ static int jsonParseValue(JsonParse *pParse, u32 i){
|
||||
}else if( c==0 ){
|
||||
return 0; /* End of file */
|
||||
}else{
|
||||
#ifdef SQLITE_ENABLE_JSON_NAN_INF
|
||||
int k, nn;
|
||||
for(k=0; k<sizeof(aNanInfName)/sizeof(aNanInfName[0]); k++){
|
||||
if( c!=aNanInfName[k].c1 && c!=aNanInfName[k].c2 ) continue;
|
||||
nn = aNanInfName[k].n;
|
||||
if( sqlite3StrNICmp(&z[i], aNanInfName[k].zMatch, nn)!=0 ){
|
||||
continue;
|
||||
}
|
||||
if( sqlite3Isalnum(z[i+nn]) ) continue;
|
||||
jsonParseAddNode(pParse, aNanInfName[k].eType,
|
||||
aNanInfName[k].nRepl, aNanInfName[k].zRepl);
|
||||
return i + nn;
|
||||
}
|
||||
#endif
|
||||
return -1; /* Syntax error */
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user