File tree Expand file tree Collapse file tree 8 files changed +23
-18
lines changed Expand file tree Collapse file tree 8 files changed +23
-18
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 @@ -12,21 +12,10 @@ an arbitrary depth.
12
12
This class is aligned with the JSON standard, [ RFC
13
13
7159] ( https://tools.ietf.org/html/rfc7159.html ) .
14
14
15
- ## Installation
15
+ ## Library usage
16
16
17
- This project is a standard GNU
18
- [ autotools] ( https://www.gnu.org/software/automake/manual/html_node/Autotools-Introduction.html )
19
- project. Build and install instructions are available in the ` INSTALL `
20
- file provided with GNU autotools.
21
-
22
- ```
23
- $ ./autogen.sh
24
- $ ./configure
25
- $ make
26
- ```
27
-
28
- ## Design
29
-
30
- UniValue provides a single dynamic RAII C++ object class,
31
- and minimizes template use (contra json_spirit).
17
+ This is a fork of univalue used by Bitcoin Core. It is not maintained for usage
18
+ by other projects. Notably, the API may break in non-backward-compatible ways.
32
19
20
+ Other projects looking for a maintained library should use the upstream
21
+ univalue at https://github.com/jgarzik/univalue .
Original file line number Diff line number Diff line change @@ -47,7 +47,6 @@ class UniValue {
47
47
std::string s (val_);
48
48
setStr (s);
49
49
}
50
- ~UniValue () {}
51
50
52
51
void clear ();
53
52
Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ bool ParseInt32(const std::string& str, int32_t *out)
35
35
errno = 0 ; // strtol will not set errno if valid
36
36
long int n = strtol (str.c_str (), &endp, 10 );
37
37
if (out) *out = (int32_t )n;
38
- // Note that strtol returns a *long int*, so even if strtol doesn't report a over/underflow
38
+ // Note that strtol returns a *long int*, so even if strtol doesn't report an over/underflow
39
39
// we still have to check that the returned value is within the range of an *int32_t*. On 64-bit
40
40
// platforms the size of these types may be different.
41
41
return endp && *endp == 0 && !errno &&
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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[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
Original file line number Diff line number Diff line change @@ -114,6 +114,7 @@ static const char *filenames[] = {
114
114
" fail41.json" , // invalid unicode: 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