Skip to content

Commit

Permalink
Fix packet parser
Browse files Browse the repository at this point in the history
  • Loading branch information
avsej committed Mar 23, 2012
1 parent d31f3a2 commit 6869e7d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/em-couchbase/packet.rb
Expand Up @@ -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] = ""
Expand Down

0 comments on commit 6869e7d

Please sign in to comment.