lib/em-websocket/framing07.rb in em-websocket-0.3.6 vs lib/em-websocket/framing07.rb in em-websocket-0.3.7

- old
+ new

@@ -57,10 +57,14 @@ # Compute the expected frame length frame_length = pointer + payload_length frame_length += 4 if mask + if frame_length > @connection.max_frame_size + raise WSMessageTooBigError, "Frame length too long (#{frame_length} bytes)" + end + # Check buffer size if @data.getbyte(frame_length - 1) == nil debug [:buffer_incomplete, @data] error = true next @@ -81,11 +85,11 @@ @data.slice!(0...pointer) frame_type = opcode_to_type(opcode) if frame_type == :continuation && !@frame_type - raise WebSocketError, 'Continuation frame not expected' + raise WSProtocolError, 'Continuation frame not expected' end if !fin debug [:moreframe, frame_type, application_data] @application_data_buffer << application_data @@ -156,10 +160,10 @@ def type_to_opcode(frame_type) FRAME_TYPES[frame_type] || raise("Unknown frame type") end def opcode_to_type(opcode) - FRAME_TYPES_INVERSE[opcode] || raise(DataError, "Unknown opcode") + FRAME_TYPES_INVERSE[opcode] || raise(WSProtocolError, "Unknown opcode") end def data_frame?(type) DATA_FRAMES.include?(type) end