diff --git a/ChangeLog b/ChangeLog index e8a1afba0d..cea1e218ae 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Sat Feb 8 15:27:02 2014 Tanaka Akira + + * lib/resolv.rb (Resolv::DNS::Message::MessageDecoder): Raise + DecodeError if no data before the limit. + Reported by Will Bryant. [ruby-core:60557] [Bug #9498] + Sat Feb 8 15:11:21 2014 Tanaka Akira * io.c (SMALLBUF): Unused macro removed. diff --git a/lib/resolv.rb b/lib/resolv.rb index 579f8885ae..6b2fa9d903 100644 --- a/lib/resolv.rb +++ b/lib/resolv.rb @@ -1528,6 +1528,7 @@ class Resolv end def get_bytes(len = @limit - @index) + raise DecodeError.new("limit exceeded") if @limit < @index + len d = @data[@index, len] @index += len return d @@ -1555,6 +1556,7 @@ class Resolv end def get_string + raise DecodeError.new("limit exceeded") if @limit <= @index len = @data[@index].ord raise DecodeError.new("limit exceeded") if @limit < @index + 1 + len d = @data[@index + 1, len] @@ -1578,6 +1580,7 @@ class Resolv limit = @index if !limit || @index < limit d = [] while true + raise DecodeError.new("limit exceeded") if @limit <= @index case @data[@index].ord when 0 @index += 1