mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-11 01:42:22 +03:00
Do not let bad hexadecimal digits in malformed JSONB cause an assertion fault.
FossilOrigin-Name: 8dec1ba1e5076ff596756e00c1e2ada0245f168a503dd1cadadf848331acfac3
This commit is contained in:
12
manifest
12
manifest
@@ -1,5 +1,5 @@
|
|||||||
C Minor\scode\schanges\sfor\sconsistency\sand\sto\ssimplify\stesting.
|
C Do\snot\slet\sbad\shexadecimal\sdigits\sin\smalformed\sJSONB\scause\san\sassertion\sfault.
|
||||||
D 2023-12-03T00:51:30.732
|
D 2023-12-03T11:54:39.886
|
||||||
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
||||||
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
||||||
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
|
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
|
||||||
@@ -688,7 +688,7 @@ F src/hash.h 3340ab6e1d13e725571d7cee6d3e3135f0779a7d8e76a9ce0a85971fa3953c51
|
|||||||
F src/hwtime.h f9c2dfb84dce7acf95ce6d289e46f5f9d3d1afd328e53da8f8e9008e3b3caae6
|
F src/hwtime.h f9c2dfb84dce7acf95ce6d289e46f5f9d3d1afd328e53da8f8e9008e3b3caae6
|
||||||
F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71
|
F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71
|
||||||
F src/insert.c 3f0a94082d978bbdd33c38fefea15346c6c6bffb70bc645a71dc0f1f87dd3276
|
F src/insert.c 3f0a94082d978bbdd33c38fefea15346c6c6bffb70bc645a71dc0f1f87dd3276
|
||||||
F src/json.c 9a79d32ad7df0f37aaca77a78278af177b7c898f719f7f3c1beb6626cf0cd88e
|
F src/json.c 0bbd116e9054eae2aa8088071f163c47050388ef83ab871c6c85b57a52bef984
|
||||||
F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa
|
F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa
|
||||||
F src/loadext.c 7432c944ff197046d67a1207790a1b13eec4548c85a9457eb0896bb3641dfb36
|
F src/loadext.c 7432c944ff197046d67a1207790a1b13eec4548c85a9457eb0896bb3641dfb36
|
||||||
F src/main.c 1b89f3de98d1b59fec5bac1d66d6ece21f703821b8eaa0d53d9604c35309f6f9
|
F src/main.c 1b89f3de98d1b59fec5bac1d66d6ece21f703821b8eaa0d53d9604c35309f6f9
|
||||||
@@ -2145,8 +2145,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
|
|||||||
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
||||||
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
||||||
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
||||||
P 0f26d38880fcbc207abcc94dbc170a7428bab1b4f0b7731aaf5bee0224000994
|
P df272bd837910ad9e03e222716a1201a601399664365f1dcf73d5932372518ed
|
||||||
R 66de56e0a2d95958c6880cf67a24bb7b
|
R 214d8647778f37447f46e39ad90ab38f
|
||||||
U drh
|
U drh
|
||||||
Z 5f7e6173dda49cfc3454a89f079d029d
|
Z 2537746c5900cbcfb749d720f1ba2129
|
||||||
# Remove this line to create a well-formed Fossil manifest.
|
# Remove this line to create a well-formed Fossil manifest.
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
df272bd837910ad9e03e222716a1201a601399664365f1dcf73d5932372518ed
|
8dec1ba1e5076ff596756e00c1e2ada0245f168a503dd1cadadf848331acfac3
|
||||||
26
src/json.c
26
src/json.c
@@ -817,15 +817,31 @@ static void jsonParseFree(JsonParse *pParse){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Translate a single byte of Hex into an integer.
|
||||||
|
** This routine only gives a correct answer if h really is a valid hexadecimal
|
||||||
|
** character: 0..9a..fA..F. But unlike sqlite3HexToInt(), it does not
|
||||||
|
** assert() if the digit is not hex.
|
||||||
|
*/
|
||||||
|
static u8 jsonHexToInt(int h){
|
||||||
|
#ifdef SQLITE_ASCII
|
||||||
|
h += 9*(1&(h>>6));
|
||||||
|
#endif
|
||||||
|
#ifdef SQLITE_EBCDIC
|
||||||
|
h += 9*(1&~(h>>4));
|
||||||
|
#endif
|
||||||
|
return (u8)(h & 0xf);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Convert a 4-byte hex string into an integer
|
** Convert a 4-byte hex string into an integer
|
||||||
*/
|
*/
|
||||||
static u32 jsonHexToInt4(const char *z){
|
static u32 jsonHexToInt4(const char *z){
|
||||||
u32 v;
|
u32 v;
|
||||||
v = (sqlite3HexToInt(z[0])<<12)
|
v = (jsonHexToInt(z[0])<<12)
|
||||||
+ (sqlite3HexToInt(z[1])<<8)
|
+ (jsonHexToInt(z[1])<<8)
|
||||||
+ (sqlite3HexToInt(z[2])<<4)
|
+ (jsonHexToInt(z[2])<<4)
|
||||||
+ sqlite3HexToInt(z[3]);
|
+ jsonHexToInt(z[3]);
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2524,7 +2540,7 @@ static void jsonReturnFromBlob(
|
|||||||
}else if( c=='0' ){
|
}else if( c=='0' ){
|
||||||
c = 0;
|
c = 0;
|
||||||
}else if( c=='x' ){
|
}else if( c=='x' ){
|
||||||
c = (sqlite3HexToInt(z[iIn+1])<<4) | sqlite3HexToInt(z[iIn+2]);
|
c = (jsonHexToInt(z[iIn+1])<<4) | jsonHexToInt(z[iIn+2]);
|
||||||
iIn += 2;
|
iIn += 2;
|
||||||
}else if( c=='\r' && z[i+1]=='\n' ){
|
}else if( c=='\r' && z[i+1]=='\n' ){
|
||||||
iIn++;
|
iIn++;
|
||||||
|
|||||||
Reference in New Issue
Block a user