File tree Expand file tree Collapse file tree 5 files changed +17
-0
lines changed Expand file tree Collapse file tree 5 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -95,6 +95,7 @@ TEST_FILES = \
95
95
$(TEST_DATA_DIR ) /fail41.json \
96
96
$(TEST_DATA_DIR ) /fail42.json \
97
97
$(TEST_DATA_DIR ) /fail44.json \
98
+ $(TEST_DATA_DIR ) /fail45.json \
98
99
$(TEST_DATA_DIR ) /fail3.json \
99
100
$(TEST_DATA_DIR ) /fail4.json \
100
101
$(TEST_DATA_DIR ) /fail5.json \
@@ -105,6 +106,7 @@ TEST_FILES = \
105
106
$(TEST_DATA_DIR ) /pass1.json \
106
107
$(TEST_DATA_DIR ) /pass2.json \
107
108
$(TEST_DATA_DIR ) /pass3.json \
109
+ $(TEST_DATA_DIR ) /pass4.json \
108
110
$(TEST_DATA_DIR ) /round1.json \
109
111
$(TEST_DATA_DIR ) /round2.json \
110
112
$(TEST_DATA_DIR ) /round3.json \
Original file line number Diff line number Diff line change 8
8
#include " univalue.h"
9
9
#include " univalue_utffilter.h"
10
10
11
+ /*
12
+ * According to stackexchange, the original json test suite wanted
13
+ * to limit depth to 22. Widely-deployed PHP bails at depth 512,
14
+ * so we will follow PHP's lead, which should be more than sufficient
15
+ * (further stackexchange comments indicate depth > 32 rarely occurs).
16
+ */
17
+ static const size_t MAX_JSON_DEPTH = 512 ;
18
+
11
19
static bool json_isdigit (int ch)
12
20
{
13
21
return ((ch >= ' 0' ) && (ch <= ' 9' ));
@@ -323,6 +331,9 @@ bool UniValue::read(const char *raw, size_t size)
323
331
stack.push_back (newTop);
324
332
}
325
333
334
+ if (stack.size () > MAX_JSON_DEPTH)
335
+ return false ;
336
+
326
337
if (utyp == VOBJ)
327
338
setExpect (OBJ_NAME);
328
339
else
Original file line number Diff line number Diff line change
1
+ [[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[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: unfinished UTF-8
115
115
" fail42.json" , // valid json with garbage following a nul byte
116
116
" fail44.json" , // unterminated string
117
+ " fail45.json" , // nested beyond max depth
117
118
" fail3.json" ,
118
119
" fail4.json" , // extra comma
119
120
" fail5.json" ,
@@ -124,6 +125,7 @@ static const char *filenames[] = {
124
125
" pass1.json" ,
125
126
" pass2.json" ,
126
127
" pass3.json" ,
128
+ " pass4.json" ,
127
129
" round1.json" , // round-trip test
128
130
" round2.json" , // unicode
129
131
" round3.json" , // bare string
You can’t perform that action at this time.
0 commit comments