Reject invalid UTF-16 surrogate pairs and lone low surrogates for clarity
CI / build (-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++, clang-arm64, ubuntu-latest-arm64, true) (push) Successful in 54s
CI / pre-commit (push) Successful in 53s
CI / build (-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++, gcc-arm64, ubuntu-latest-arm64, false) (push) Successful in 50s
CI / build (-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++, clang-amd64, ubuntu-latest-amd64, true) (push) Successful in 1m32s
CI / build (-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++, gcc-amd64, ubuntu-latest-amd64, false) (push) Successful in 1m24s
CI / build (-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++, clang-arm64, ubuntu-latest-arm64, true) (push) Successful in 54s
CI / pre-commit (push) Successful in 53s
CI / build (-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++, gcc-arm64, ubuntu-latest-arm64, false) (push) Successful in 50s
CI / build (-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++, clang-amd64, ubuntu-latest-amd64, true) (push) Successful in 1m32s
CI / build (-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++, gcc-amd64, ubuntu-latest-amd64, false) (push) Successful in 1m24s
The string unescape logic treated any code unit in the surrogate range (0xD800-0xDFFF) as the start of a surrogate pair. The concrete example from issue #39 (\uDC00\uDC00) was already rejected by the existing 0x10FFFF bounds check, but the check was misleading and would accept a lone low surrogate as a regular BMP code point if the second surrogate happened to be in a narrower range. Clean this up so the intent is obvious. Changes in src/parser3.h: - Fast path (n_string2): only treat high surrogates (0xD800-0xDBFF) as the start of a surrogate pair, and explicitly reject lone low surrogates (0xDC00-0xDFFF). - Slow path (t_hex2): same high-surrogate check, with explicit rejection of lone low surrogates. The t_hex3 path already validates that the second code unit is a low surrogate (0xDC00-0xDFFF), so no change is needed there. Also commit the current fuzzer corpus. Closes #39
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
[4,[5,[5,[4,[6,[5,[5,55,5,[[5,[4,[5,[5,[5,5,[5,[5,[[5,[5,[415,[4,[5,[5,[3,[5,5,[5,[5,[[null,[415,[[5,[5,[415,4,5,[[5,5,[5,[5,[[null,5,[5,[5,[[5,[5,[415,[4,[5,[5,[3,[5,[5,[5,5,[[5,[4,[5,[[5,5,[5,[5,[[null,[415,[4,[5,[[5,[4,[5,[5,[5,5,[5,[5,[[5,[5,[415,[4,[5,[5,[4,[5,[5,[5,5,[[5,[4,[5,[[5,5,[5,[5,[[null,[415,[4,[5,[5,[4,5,[5,5,[[5,[4,[5,[[5,5,[5,[5,[[null,[413,[5,[5,[5,5,[[5,[4,[5,[[5,5,[5,[5,[[null,[415,[4,[5,[[5,[4,[5,[5,[5,5,[5,[5,[[5,[5,[415,[4,[5,[5,[4,[5,[5,[5,5,[[5,[4,[5,[[5,5,[5,[5,[[null,[415,[4,[5,[5,[4,5,[5,5,4,[5,[5,[5,5,[5,[5,[[5,[5,[415,[4,[5,[5,[[5,[[null,[415,[4,[5,[[5,[4,[5,[5,[5,5,[5,[5,[[5,[5,[415,[4,[5,[5,[4,[5,[5,[5,5,[[5,[4,[5,[[5,5,[5,[5,[[null,[415,[4,[5,[5,[4,5,[5,5,[[[5,5,[5,[5,[[null,[415,[[5,[5,[415,4,5,[[5,5,[5,[5,[[null,5,[5,[5,[[5,[5,[415,[4,[5,[5,[3,[5,[5,[5,5,[[5,[4,[5,[[5,5,[5,[5,[[null,[415,[4,[5,[[5,[4,[5,[5,[5,5,[5,[5,[[5,[5,[415,[4,[5,[5,[4,[5,[5,[5,5,[[5,[4,[5,[[5,5,[5,[5,[[null,[415,[4,[5,[5,[4,5,[5,5,[[5,[4,[5,[[5,5,[5,[5,[[null,[413,[5,[5,[5,5,[[5,[4,[5,[[5,5,[5,[5,[[null,[415,[4,[5,[[5,[4,[5,[5,[5,5,[5,[5,[[5,[5,[415,[4,[5,[5,[4,[5,[5,[5,5,[[5,[4,[5,[[5,5,[5,[5,[[null,[415,[4,[5,[5,[4,5,[[[[5,5,[5,[5,[[null,[461,[[5,[5,[415,4,5,[[5,5,[5,[5,[[null,5,[5,[5,5,[5,[5,[[5,[5,[415,[4,[5,[5,[4,[5,[5,[5,5,[[5,[4,[5,[[5,5,[5,[5,[[null,[415,[4,[5,[5,[4,5,[5,5,[[[[[-41.8,[8,[8,[[[[ [[[
|
||||
[[-41,{},[[[[{},{}, [[[{},{},[[false, [[false, [[[{},8,[-41.8,[8,[8,[[[[[-20.8,[8,[8,[[1.8,[3,[8,[[[[ [[[
|
||||
[[-418,[8,[[[
|
||||
[[-41,{},[[false, [[false, [[[{},8,[-41.8,[8,[8,[[[[[-41.8,[8,[8,[[[[ [[[ [[-41.8,[3,[8,[[[[ [[[
|
||||
[[-418,[8,[[[
|
||||
[[-41.8,[8,[8,
|
||||
[[-41.8,[-41.8,[8,[8,8,[8,[8,[[[[[-41.8,[8,[
|
||||
[[-418,[8,[[[[[[-41.8,[8,[8,[[[[ [[[
|
||||
[[-41,{},[[[[{},{}, [[[{},{},[[false, [[false, [[[{},8,[-41.8,[8,[8.8,[8,[[[{},{}, [[[{},{},[[false, [[false, [[[{},8, [[[
|
||||
[[-41,{},[[[[{},{}, [[[{},{},[[false, [[false, [[-418,[8,[[[
|
||||
[[-41.8,[8,[8,
|
||||
[[-41.8,[-41.8,[8,[8,[[[[[-41.8,[8,[
|
||||
[[-418,[8,[[␍[[[[-41.8,[8,[8,[[[[ [[[
|
||||
[[-41,{},[[[[{},{}, [[[{},{},[[false, [[false, [[[{},8,[-41.8,[8,[8,[[[[[-20.8,[8,[8,[[1.8,[3,[8,[[[[ [[[3,[8,[[[[ [[[
|
||||
[[-418,[8,[[[
|
||||
[[-41.8,[8,[8,
|
||||
[[-41.8,[-41.8,[8,[8,[[[[[-41.8,[8,[
|
||||
[[-418,[8,[[[[[[-41.8,[8,[8,[[[[41.8,[8,[8,[[[[ [[[ [[-41.8,[3,[8,[[[[ [[[
|
||||
[[-418,[8,[[[
|
||||
[[-41.8,[8,[8,
|
||||
[[-41.8,[-41.8,[8,[8,[[[[[-41.8,[8,[
|
||||
[[-41,5,[[5,[4,[5,[[5,5,[5,[5,[[null,[415,[4,[5,[5,[4,5,[[[[5,5,[5,[5,[[null,[415,[[5,[5,[415,4,5,[[5,[[[41.8,[8,[8,[[[[ [[[ [[-41.8,[3,[8,[[[[ [[[
|
||||
[[-418,[8,[[[
|
||||
[[-41.8,[8,[8,
|
||||
[[-41.8,[-41.8,[8,[8,[[[[[-41.8,[8,[
|
||||
[[-418,[8,[[[[[[-41.8,[8,[8,[[[[ [[8,[[[[[[-41.8,[8,[8,[[[[41.8,[8,[8,[[[[ [[[ [[-41.8,[3,[8,[[[[ [[[
|
||||
[[-418,[8,[[[
|
||||
[[-41.8,[8,[8,
|
||||
[[-41.8,[-41.8,[8,[8,[[[[[-41.8,[8,[
|
||||
[[-418,[8,[[[[[[-41.8,[8,[8,[[[[ [[[
|
||||
[[-41,{},[[[[{},{}, [[[{},{},[[false, [[false, [[[{},8,[-41.8,[8,[8,[[[[[8,[8,[8,
|
||||
[[-41.8,[-41.8,[8,[8,[[[[[-41.8,[8,[
|
||||
[[-418,[8,[[[[[[-41.8,[8,[8,[[[[ [[[
|
||||
[[-41,{},[[[[{},{}, [[[{},{},[[false, [[false, [[[{},8,[-41.8,[8,[8,[[[[[-20.8,[8,[8,[[1.8,[3,[8,[[[[ [[[
|
||||
[[-418,[8,[[[
|
||||
[[-41,{},[[false, [[false, [[[{},8,[-41.8,[8,[8,[[[[[-41.8,[8,[8,[[[[ [[[ [[-41.8,[3,[8,[[[[ [[[
|
||||
[[-418,[8,[[[
|
||||
[[-41.8,[8,[8,
|
||||
[[-41.8,[-41.8,[8,[8,[[[[[-41.8,[8,[
|
||||
[[-418,[8,[[[[[[-.41.8,[8,[7,[[[[41.8,[8,[8,[[[[ [[[ [[-41.8,[3,[8,[[[[ [[[
|
||||
[[-418,[8,[[[
|
||||
[[-41.8,[8,[8,
|
||||
[[-41.8,[-41.8,[8,[8,[[5,[5,[[null,5,[1.0e+9, ""[[{},{}:0 -1.0e028 },[[false, [[false, [[[{},8,
|
||||
Reference in New Issue
Block a user