Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/protocol/websocket/frame.rb
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def self.read(finished, flags, opcode, stream, maximum_frame_size)
end

if length > maximum_frame_size
raise ProtocolError, "Invalid payload length: #{@length} > #{maximum_frame_size}!"
raise ProtocolError, "Invalid payload length: #{length} > #{maximum_frame_size}!"
end

if mask
Expand All @@ -195,7 +195,7 @@ def self.read(finished, flags, opcode, stream, maximum_frame_size)
payload = stream.read(length) or raise EOFError, "Could not read payload!"

if payload.bytesize != length
raise EOFError, "Incorrect payload length: #{@length} != #{payload.bytesize}!"
raise EOFError, "Incorrect payload length: #{length} != #{payload.bytesize}!"
end

return self.new(finished, payload, flags: flags, opcode: opcode, mask: mask)
Expand Down
4 changes: 2 additions & 2 deletions test/protocol/websocket/frame.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,15 @@

expect do
subject.read(false, 0, 0, stream, 124)
end.to raise_exception(Protocol::WebSocket::ProtocolError, message: be =~ /Invalid payload length/)
end.to raise_exception(Protocol::WebSocket::ProtocolError, message: be =~ /Invalid payload length: \d+ > \d*!/)
end

it "rejects frames with truncated payload" do
stream = StringIO.new("\x051234")

expect do
subject.read(false, 0, 0, stream, 128)
end.to raise_exception(EOFError, message: be =~ /Incorrect payload length/)
end.to raise_exception(EOFError, message: be =~ /Incorrect payload length: \d+ != \d+!/)
end
end

Expand Down
Loading