Raise std/json's max number length from 49 to 99

This commit is contained in:
Nigel Tao committed 2020-02-24 11:27:34 +11:00
1 parent 6b161af654
commit 83ae50ce9b
2 files changed
+10 -2

No files matched your search

+9 -1
View File
@@ -690,7 +690,15 @@ pri func decoder.decode_digits!(src: base.io_reader, n: base.u32[..= 0xFF]) base
if (c < 0x30) or (0x39 < c) {
break
}
if n >= 49 {
// Cap the maximum supported number length at an arbitrary value, 99.
// The caller's src.data.len should therefore be at least 100.
//
// An example of a JSON number that is 81 bytes long is:
// https://github.com/nst/JSONTestSuite/blob/master/test_parsing/y_number_double_close_to_zero.json
//
// Note that 99 (in hex, 0x63) is less than 0x80, so we can use 0x80 as
// a flag bit in func decoder.decode_number.
if n >= 99 {
n |= 0x200
break
}