xdr 2.0.0 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 841aa4d6061ac4e1989f6eb231c3b78fdc69b43f
4
- data.tar.gz: d3342bce08c239465be256c53311d242d15fe658
2
+ SHA256:
3
+ metadata.gz: 0d5bbd8152326ee17057091ea8a9ec722f07ad88c74bf9717b16cdab900401e5
4
+ data.tar.gz: 60dfea4235d890dc70553903b5130ed05e5c98e83bc3586ecf0bd7e447cb205e
5
5
  SHA512:
6
- metadata.gz: faaa298dac8ceed46a0f9d7c654e5e4daad1bf8fad2dfdd1cee350c84ec54c653b193653289ef4fecbc92922f72e79c32a41285a59b392f98c14e596861afd6a
7
- data.tar.gz: 1bc9c094fec32a7e39338122696fb58cb3058099f29929abf7b87da9972d3ddab2e1e58ca691ac3ab8956694ffb767eb354ec6f39b3c80b9245be3f74123757b
6
+ metadata.gz: d74217c94b1cbb5a7e0c6b1bcf14547c5b5d186b6bcabe6c078b5d941ac3953dd32ab652f151f8ed970c8c6fc92cbcee2e7608ab6c3b3d57e6d7de1080a780e6
7
+ data.tar.gz: cf5d7fd46ef66e83c70860d52ef50dab523af310ab2aba5f7cc06543791adac5d8afbefd8480734f1a34259ecdd2da2c5921f30e90fc84113f89bb006ae5d7de
@@ -6,6 +6,11 @@ file. This project adheres to [Semantic Versioning](http://semver.org/).
6
6
  As this project is pre 1.0, breaking changes may happen for minor version
7
7
  bumps. A breaking change will get clearly notified in this log.
8
8
 
9
+ ## [Unreleased](https://github.com/stellar/ruby-stellar-base/compare/v1.0.0...master)
10
+
11
+ ### Fixed
12
+ - Padding bytes are now properly validated when reading xdr values. According to the XDR spec, padding must be zeros.
13
+
9
14
  ## [1.0.0](https://github.com/stellar/ruby-stellar-base/compare/v0.1.0...v1.0.0)
10
15
 
11
16
  ### Added
@@ -5,4 +5,12 @@ module XDR::Concerns::ReadsBytes
5
5
  raise EOFError if bytes.nil? || bytes.length != length
6
6
  end
7
7
  end
8
+
9
+ def read_zeros(io, length)
10
+ read_bytes(io, length).each_byte do |byte|
11
+ raise XDR::ReadError unless byte == 0
12
+ end
13
+
14
+ nil
15
+ end
8
16
  end
@@ -12,7 +12,7 @@ class XDR::Opaque
12
12
  def read(io)
13
13
  # read and return @length bytes
14
14
  # throw away @padding bytes
15
- read_bytes(io, @length).tap{ read_bytes(io, @padding) }
15
+ read_bytes(io, @length).tap{ read_zeros(io, @padding) }
16
16
  end
17
17
 
18
18
  def write(val,io)
@@ -31,6 +31,6 @@ class XDR::String
31
31
 
32
32
  # read and return length bytes
33
33
  # throw away padding bytes
34
- read_bytes(io, length).tap{ read_bytes(io, padding) }
34
+ read_bytes(io, length).tap{ read_zeros(io, padding) }
35
35
  end
36
36
  end
@@ -31,6 +31,6 @@ class XDR::VarOpaque
31
31
 
32
32
  # read and return length bytes
33
33
  # throw away padding bytes
34
- read_bytes(io, length).tap{ read_bytes(io, padding) }
34
+ read_bytes(io, length).tap{ read_zeros(io, padding) }
35
35
  end
36
36
  end
@@ -1,3 +1,3 @@
1
1
  module XDR
2
- VERSION = "2.0.0"
2
+ VERSION = "3.0.0"
3
3
  end
@@ -3,6 +3,7 @@ require 'spec_helper'
3
3
  class TestReader
4
4
  include XDR::Concerns::ReadsBytes
5
5
  public :read_bytes
6
+ public :read_zeros
6
7
  end
7
8
 
8
9
 
@@ -28,4 +29,29 @@ describe XDR::Concerns::ReadsBytes, "#read_bytes" do
28
29
  io = StringIO.new(str)
29
30
  subject.read_bytes(io, length)
30
31
  end
32
+ end
33
+
34
+
35
+ describe XDR::Concerns::ReadsBytes, "#read_zeros" do
36
+ subject{ TestReader.new }
37
+
38
+ it "raises XDR::ReadError when the bytes read do not equal zero" do
39
+ expect{ read("\x01", 1) }.to raise_error(XDR::ReadError)
40
+ end
41
+
42
+ it "succeeds when all the bytes read are zero" do
43
+ expect{ read("\x00\x00\x00\x00", 1) }.to_not raise_error
44
+ expect{ read("\x00\x00\x00\x00", 2) }.to_not raise_error
45
+ expect{ read("\x00\x00\x00\x00", 3) }.to_not raise_error
46
+ expect{ read("\x00\x00\x00\x00", 4) }.to_not raise_error
47
+ end
48
+
49
+ it "raises EOFError when the requested length goes beyond the length of the stream" do
50
+ expect{ read("\x00\x00\x00\x00", 5) }.to raise_error(EOFError)
51
+ end
52
+
53
+ def read(str, length)
54
+ io = StringIO.new(str)
55
+ subject.read_zeros(io, length)
56
+ end
31
57
  end
@@ -9,6 +9,10 @@ describe XDR::Opaque, "#read" do
9
9
  expect(read("\x00\x01\x00\x00")).to eq("\x00\x01\x00")
10
10
  end
11
11
 
12
+ it "raises a ReadError when the padding isn't zeros" do
13
+ expect{ read "\x00\x00\x01\x01" }.to raise_error(XDR::ReadError)
14
+ end
15
+
12
16
  def read(str)
13
17
  io = StringIO.new(str)
14
18
  subject.read(io)
@@ -14,6 +14,12 @@ describe XDR::String, "#read" do
14
14
  expect{ read "\x00\x00\x00\x04hiya" }.to raise_error(XDR::ReadError)
15
15
  end
16
16
 
17
+ it "raises a ReadError when the padding isn't zeros" do
18
+ expect{ read "\x00\x00\x00\x01h\x00\x00\x01" }.to raise_error(XDR::ReadError)
19
+ expect{ read "\x00\x00\x00\x01h\x00\x01\x00" }.to raise_error(XDR::ReadError)
20
+ expect{ read "\x00\x00\x00\x01h\x01\x00\x00" }.to raise_error(XDR::ReadError)
21
+ end
22
+
17
23
  def read(str)
18
24
  io = StringIO.new(str)
19
25
  subject.read(io)
@@ -15,6 +15,13 @@ describe XDR::VarOpaque, "#read" do
15
15
  expect{ read "\x00\x00\x00\x03\x00\x00\x00\x00" }.to raise_error(XDR::ReadError)
16
16
  end
17
17
 
18
+
19
+ it "raises a ReadError when the padding isn't zeros" do
20
+ expect{ read "\x00\x00\x00\x01\x01\x00\x00\x01" }.to raise_error(XDR::ReadError)
21
+ expect{ read "\x00\x00\x00\x01\x01\x00\x01\x00" }.to raise_error(XDR::ReadError)
22
+ expect{ read "\x00\x00\x00\x01\x01\x01\x00\x00" }.to raise_error(XDR::ReadError)
23
+ end
24
+
18
25
  def read(str)
19
26
  io = StringIO.new(str)
20
27
  subject.read(io)
@@ -17,8 +17,8 @@ Gem::Specification.new do |spec|
17
17
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
- spec.add_dependency "activesupport", ">= 4.2.7"
21
- spec.add_dependency "activemodel", ">= 4.2.7"
20
+ spec.add_dependency "activesupport", ">= 5.2.0"
21
+ spec.add_dependency "activemodel", ">= 5.2.0"
22
22
 
23
23
  spec.add_development_dependency "bundler", "~> 1.7"
24
24
  spec.add_development_dependency "rake", "~> 10.0"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xdr
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scott Fleckenstein
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-02 00:00:00.000000000 Z
11
+ date: 2018-07-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 4.2.7
19
+ version: 5.2.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 4.2.7
26
+ version: 5.2.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: activemodel
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 4.2.7
33
+ version: 5.2.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: 4.2.7
40
+ version: 5.2.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -210,7 +210,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
210
210
  version: '0'
211
211
  requirements: []
212
212
  rubyforge_project:
213
- rubygems_version: 2.4.5.2
213
+ rubygems_version: 2.7.6
214
214
  signing_key:
215
215
  specification_version: 4
216
216
  summary: XDR Helper Library