Method: Rex::Java::Serialization::Model::Utf#decode

Defined in:
lib/rex/java/serialization/model/utf.rb

#decode(io) ⇒ self

Deserializes a Rex::Java::Serialization::Model::Utf

Parameters:

  • io (IO)

    the io to read from

Returns:

  • (self)

    if deserialization succeeds

Raises:



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/rex/java/serialization/model/utf.rb', line 30

def decode(io)
  raw_length = io.read(2)
  if raw_length.nil? || raw_length.length != 2
    raise ::RuntimeError, 'Failed to unserialize Utf'
  end
  self.length = raw_length.unpack('n')[0]

  if length == 0
    self.contents = ''
  else
    self.contents = io.read(length)
    if contents.nil? || contents.length != length
      raise ::RuntimeError, 'Failed to unserialize Utf'
    end
  end

  self
end