oj 2.6.0 → 2.6.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of oj might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 88d1b989da1bbd42c7fa90ba96baa9c71f289631
4
- data.tar.gz: 2d1643092b53fbf33db538856179f7385516346e
3
+ metadata.gz: 47818e1b552b974e400bd82db1723ecf930100ed
4
+ data.tar.gz: 48f46104df400dab9f9b1c838b7247d68b34c1c3
5
5
  SHA512:
6
- metadata.gz: 6433a3aa13a1afdabda2e44c732cc85989a38772702edf5ca70a984e9dbdc275f7a255cb405897e8b6898aced26490f11c17b55413638dd885bba2c9a7ed8a54
7
- data.tar.gz: 79540125a8c5a1553622f786e5aee3a12c8e256060f545a87ae0d9bb5896ab7dc0e5bb4bcdc1f72d6a354d35c5a536adb8cde20bc11a128464405460b8e8a112
6
+ metadata.gz: fa8d739990ecce865cf95bd363a6464b343cd29d6ab8af6a1bf19e3dd21029d8000f990084a03990822e3f7c88e3164476e7e2b9d8295b2d0e36a5b0dadf5194
7
+ data.tar.gz: a02d4f7b1b07caee178e7ec726dedaa481c5c429777dc4be0f2ba9ed361aab57e040ad4ce1abd2e71d79836bad57702f32b180703ffae46e4e0f939e30c397c9
data/README.md CHANGED
@@ -26,12 +26,11 @@ Follow [@peterohler on Twitter](http://twitter.com/#!/peterohler) for announceme
26
26
 
27
27
  [![Build Status](https://secure.travis-ci.org/ohler55/oj.png?branch=master)](http://travis-ci.org/ohler55/oj)
28
28
 
29
- ### Current Release 2.6.0
29
+ ### Current Release 2.6.1
30
30
 
31
- - Added the `:use_to_json` option for Oj.dump(). If this option is set to false
32
- the `to_json()` method on objects will not be calledwhen dumping. This is the
33
- default behavior. The reason behind the option and change is to better
34
- support Rails and ActiveSupport. Previous works arounds have been removed.
31
+ - Set a limit on the maximum nesting depth to 1000. An exception is raised
32
+ instead of a segfault unless a reduced stack is used which could trigger the
33
+ segfault due to an out of memory condition.
35
34
 
36
35
  [Older release notes](http://www.ohler.com/dev/oj_misc/release_notes.html).
37
36
 
@@ -54,6 +54,8 @@
54
54
  // Extra padding at end of buffer.
55
55
  #define BUFFER_EXTRA 10
56
56
 
57
+ #define MAX_DEPTH 1000
58
+
57
59
  typedef unsigned long ulong;
58
60
 
59
61
  static void raise_strict(VALUE obj);
@@ -182,19 +184,6 @@ fill_indent(Out out, int cnt) {
182
184
  }
183
185
  }
184
186
 
185
- inline static const char*
186
- ulong2str(uint32_t num, char *end) {
187
- char *b;
188
-
189
- *end-- = '\0';
190
- for (b = end; 0 < num || b == end; num /= 10, b--) {
191
- *b = (num % 10) + '0';
192
- }
193
- b++;
194
-
195
- return b;
196
- }
197
-
198
187
  inline static void
199
188
  dump_ulong(unsigned long num, Out out) {
200
189
  char buf[32];
@@ -1620,6 +1609,9 @@ raise_strict(VALUE obj) {
1620
1609
 
1621
1610
  static void
1622
1611
  dump_val(VALUE obj, int depth, Out out) {
1612
+ if (MAX_DEPTH < depth) {
1613
+ rb_raise(rb_eNoMemError, "Too deeply nested.\n");
1614
+ }
1623
1615
  switch (rb_type(obj)) {
1624
1616
  case T_NIL: dump_nil(out); break;
1625
1617
  case T_TRUE: dump_true(out); break;
@@ -147,23 +147,6 @@ next_non_white(ParseInfo pi) {
147
147
  }
148
148
  }
149
149
 
150
- inline static void
151
- next_white(ParseInfo pi) {
152
- for (; 1; pi->s++) {
153
- switch(*pi->s) {
154
- case ' ':
155
- case '\t':
156
- case '\f':
157
- case '\n':
158
- case '\r':
159
- case '\0':
160
- return;
161
- default:
162
- break;
163
- }
164
- }
165
- }
166
-
167
150
  inline static char*
168
151
  ulong_fill(char *s, size_t num) {
169
152
  char buf[32];
@@ -120,23 +120,6 @@ next_non_white(ParseInfo pi) {
120
120
  }
121
121
  }
122
122
 
123
- inline static void
124
- next_white(ParseInfo pi) {
125
- for (; 1; pi->s++) {
126
- switch(*pi->s) {
127
- case ' ':
128
- case '\t':
129
- case '\f':
130
- case '\n':
131
- case '\r':
132
- case '\0':
133
- return;
134
- default:
135
- break;
136
- }
137
- }
138
- }
139
-
140
123
  inline static void
141
124
  call_add_value(VALUE handler, VALUE value, const char *key) {
142
125
  volatile VALUE k;
@@ -1,5 +1,5 @@
1
1
 
2
2
  module Oj
3
3
  # Current version of the module.
4
- VERSION = '2.6.0'
4
+ VERSION = '2.6.1'
5
5
  end
@@ -178,7 +178,7 @@ class SajTest < ::Test::Unit::TestCase
178
178
  json = %{12345xyz}
179
179
  Oj.saj_parse(handler, json)
180
180
  assert_equal([[:add_value, 12345, nil],
181
- [:error, "invalid format, extra characters at line 1, column 6 [saj.c:705]", 1, 6]], handler.calls)
181
+ [:error, "invalid format, extra characters at line 1, column 6 [saj.c:688]", 1, 6]], handler.calls)
182
182
  end
183
183
 
184
184
  end
@@ -1023,6 +1023,18 @@ class Juice < ::Test::Unit::TestCase
1023
1023
  end
1024
1024
  end
1025
1025
 
1026
+ def test_deep_nest_dump
1027
+ begin
1028
+ a = []
1029
+ 10000.times { a << [a] }
1030
+ Oj.dump(a)
1031
+ rescue Exception => e
1032
+ assert(true)
1033
+ return
1034
+ end
1035
+ assert(false, "*** expected an exception")
1036
+ end
1037
+
1026
1038
  # Stream IO
1027
1039
  def test_io_string
1028
1040
  src = { 'x' => true, 'y' => 58, 'z' => [1, 2, 3]}
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oj
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.6.0
4
+ version: 2.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Ohler
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-11 00:00:00.000000000 Z
11
+ date: 2014-03-21 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: 'The fastest JSON parser and object serializer. '
14
14
  email: peter@ohler.com
@@ -128,3 +128,4 @@ signing_key:
128
128
  specification_version: 4
129
129
  summary: A fast JSON parser and serializer.
130
130
  test_files: []
131
+ has_rdoc: true