[svn] commit: r109 - /experiments/graff-ccapi/msgq/ /experiments/graff-ccapi/python/ /experiments/graff-ccapi/ruby/ /trunk/src/bin/ /trunk/src/bin/msgq/ /trunk/src/lib/cc/ /trunk/src/lib/cc/python/ /trunk/src/lib/cc/ruby/ /trunk/src/lib/cc/ruby/lib/cc/

BIND 10 source code commits bind10-changes at lists.isc.org
Tue Oct 20 16:55:58 UTC 2009


Author: mgraff
Date: Tue Oct 20 16:55:58 2009
New Revision: 109

Log:
move ccapi to trunk

Added:
    trunk/src/bin/
    trunk/src/bin/msgq/
      - copied from r108, experiments/graff-ccapi/msgq/
    trunk/src/lib/cc/
    trunk/src/lib/cc/python/
      - copied from r108, experiments/graff-ccapi/python/
    trunk/src/lib/cc/ruby/
      - copied from r108, experiments/graff-ccapi/ruby/
Removed:
    experiments/graff-ccapi/msgq/
    experiments/graff-ccapi/python/
    experiments/graff-ccapi/ruby/
Modified:
    trunk/src/lib/cc/ruby/lib/cc/message.rb

Modified: trunk/src/lib/cc/ruby/lib/cc/message.rb
==============================================================================
--- trunk/src/lib/cc/ruby/lib/cc/message.rb (original)
+++ trunk/src/lib/cc/ruby/lib/cc/message.rb Tue Oct 20 16:55:58 2009
@@ -68,6 +68,9 @@
   # Decode a wire format message.
   #
   def self.from_wire(msg)
+    if msg.length < 4
+      raise CC::DecodeError, "Data is too short to decode"
+    end
     CC::set_binary(msg)
     version, msg = msg.unpack("N a*")
     unless version == PROTOCOL_VERSION
@@ -158,13 +161,22 @@
   end
 
   def self.decode_tag(str)
+    if str.length < 1
+      raise CC::DecodeError, "Data underrun while decoding"
+    end
     length = str.unpack("C")[0]
+    if str.length - 1 < length
+      raise CC::DecodeError, "Data underrun while decoding"
+    end
     tag, remainder = str.unpack("x a#{length} a*")
     CC::set_utf8(tag)
     [ tag, remainder ]
   end
 
   def self.decode_item(msg)
+    if msg.length < 1
+      raise CC::DecodeError, "Data underrun while decoding"
+    end
     type_and_length_format = msg.unpack("C")[0]
     type = type_and_length_format & ITEM_MASK
     length_format = type_and_length_format & ITEM_LENGTH_MASK
@@ -173,11 +185,23 @@
       msg = msg.unpack("x a*")[0]
     else
       if length_format == ITEM_LENGTH_8
+        if msg.length - 1 < 1
+          raise CC::DecodeError, "Data underrun while decoding"
+        end
         length, msg = msg.unpack("x C a*")
       elsif length_format == ITEM_LENGTH_16
+        if msg.length - 1 < 2
+          raise CC::DecodeError, "Data underrun while decoding"
+        end
         length, msg = msg.unpack("x n a*")
       elsif length_format == ITEM_LENGTH_32
+        if msg.length - 1 < 4
+          raise CC::DecodeError, "Data underrun while decoding"
+        end
         length, msg = msg.unpack("x N a*")
+      end
+      if msg.length < length
+        raise CC::DecodeError, "Data underrun while decoding"
       end
       item, msg = msg.unpack("a#{length} a*")
     end




More information about the bind10-changes mailing list