mtik 3.0.4 → 3.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/CHANGELOG.txt +5 -0
  2. data/VERSION.txt +1 -1
  3. data/lib/mtik/request.rb +12 -8
  4. metadata +3 -3
@@ -1,3 +1,8 @@
1
+ 2010-04-23 (23 APR 2010) VERSION 3.0.5 Aaron D. Gifford (http://www.aarongifford.com)
2
+ * Double bug-fix (typo fix and logic fix) to request.rb thanks to Allan Eising and
3
+ Søren Daugaard. Thank you both for the patch!
4
+ * Added a brief sanity-check in request.rb to help spotlight logic errors.
5
+
1
6
  2010-04-09 (09 APR 2010) VERSION 3.0.4 Aaron D. Gifford (http://www.aarongifford.com)
2
7
  * Bug fix to lib/mtik.rb thanks to Allan Eising to the command validation regular
3
8
  expression to permit the '-' character in a command. Thanks!
@@ -1 +1 @@
1
- 3.0.4
1
+ 3.0.5
@@ -157,16 +157,20 @@ class MTik::Request < Array
157
157
 
158
158
  ## Utility method for packing an unsigned integer as
159
159
  ## a binary byte string of variable length
160
- def self.bytepack(num)
160
+ def self.bytepack(num, size)
161
161
  s = String.new
162
- if RUBY_VERSIION >= '1.9.0'
162
+ if RUBY_VERSION >= '1.9.0'
163
163
  s.force_encoding(Encoding::BINARY)
164
164
  end
165
165
  x = num < 0 ? -num : num ## Treat as unsigned
166
- while x > 0
167
- s += (x & 0xff).chr
166
+ while size > 0
167
+ size -= 1
168
+ s = (x & 0xff).chr + s
168
169
  x >>= 8
169
170
  end
171
+ raise RuntimeError.new(
172
+ "Number #{num} is too large to fit in #{size} bytes."
173
+ ) if x > 0
170
174
  return s
171
175
  end
172
176
 
@@ -180,13 +184,13 @@ class MTik::Request < Array
180
184
  if str.length < 0x80
181
185
  return str.length.chr + str
182
186
  elsif str.length < 0x4000
183
- return bytepack(str.length | 0x8000) + str
187
+ return bytepack(str.length | 0x8000, 2) + str
184
188
  elsif str.length < 0x200000
185
- return bytepack(str.length | 0xc00000) + str
189
+ return bytepack(str.length | 0xc00000, 3) + str
186
190
  elsif str.length < 0x10000000
187
- return bytepack(str.length | 0xe0000000) + str
191
+ return bytepack(str.length | 0xe0000000, 4) + str
188
192
  elsif str.length < 0x0100000000
189
- return 0xf0.chr + bytepack(str.length) + str
193
+ return 0xf0.chr + bytepack(str.length, 5) + str
190
194
  else
191
195
  raise RuntimeError.new(
192
196
  "String is too long to be encoded for " +
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 3
7
7
  - 0
8
- - 4
9
- version: 3.0.4
8
+ - 5
9
+ version: 3.0.5
10
10
  platform: ruby
11
11
  authors:
12
12
  - Aaron D. Gifford
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-04-09 00:00:00 -06:00
17
+ date: 2010-04-23 00:00:00 -06:00
18
18
  default_executable:
19
19
  dependencies: []
20
20