Permalink
Browse files

Fix packet parser

  • Loading branch information...
1 parent d31f3a2 commit 6869e7d3824d1a89b2da74ceb339c0b03e3b7fc1 @avsej committed Mar 23, 2012
Showing with 5 additions and 1 deletion.
  1. +5 −1 lib/em-couchbase/packet.rb
View
6 lib/em-couchbase/packet.rb
@@ -152,7 +152,11 @@ def self.parse(data)
opaque,
cas ) = header.unpack(RESPONSE_HEADER_FMT)
- if data.length < bodylen
+ if magic != 0x81
+ fail Couchbase::Error::Protocol.new "Broken packet: #{header.inspect}"
+ end
+
+ if data.size < bodylen + RESPONSE_HEADER_SIZE
return # need moar data
else
data[0...RESPONSE_HEADER_SIZE] = ""

0 comments on commit 6869e7d

Please sign in to comment.