bencode_ext 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/bencode_ext.gemspec +1 -1
- data/ext/bencode_ext/bencode.c +2 -0
- data/test/test_bencode_ext.rb +4 -0
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.1
|
data/bencode_ext.gemspec
CHANGED
data/ext/bencode_ext/bencode.c
CHANGED
@@ -87,6 +87,8 @@ static VALUE decode(VALUE self, VALUE encoded){
|
|
87
87
|
crt = *str == 'l' ? rb_ary_new() : rb_hash_new();
|
88
88
|
NEXT_CHAR;
|
89
89
|
if(NIL_P(current_container)){
|
90
|
+
if(max_depth == 0)
|
91
|
+
rb_raise(DecodeError, "Structure is too deep!");
|
90
92
|
ret = current_container = crt;
|
91
93
|
continue;
|
92
94
|
}
|
data/test/test_bencode_ext.rb
CHANGED
@@ -31,6 +31,10 @@ class TestBencodeExt < Test::Unit::TestCase
|
|
31
31
|
BEncode.max_depth = 1
|
32
32
|
'lli1eee'.bdecode
|
33
33
|
end
|
34
|
+
assert_raises(BEncode::DecodeError) do
|
35
|
+
BEncode.max_depth = 0
|
36
|
+
'li1ee'.bdecode
|
37
|
+
end
|
34
38
|
assert_nothing_raised(BEncode::DecodeError) do
|
35
39
|
BEncode.max_depth = 0
|
36
40
|
'i1e'.bdecode
|