Exception: Msf::BadcharError

Inherits:
EncodingError show all
Defined in:
lib/msf/core/exceptions.rb

Overview

Thrown when an encoder fails to encode a buffer due to a bad character.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(buf = nil, index = nil, stub_size = nil, char = nil) ⇒ BadcharError


97
98
99
100
101
102
# File 'lib/msf/core/exceptions.rb', line 97

def initialize(buf = nil, index = nil, stub_size = nil, char = nil)
  @buf       = buf
  @index     = index
  @stub_size = stub_size
  @char      = char
end

Instance Attribute Details

#bufObject (readonly)

Returns the value of attribute buf


119
120
121
# File 'lib/msf/core/exceptions.rb', line 119

def buf
  @buf
end

#charObject (readonly)

Returns the value of attribute char


119
120
121
# File 'lib/msf/core/exceptions.rb', line 119

def char
  @char
end

#indexObject (readonly)

Returns the value of attribute index


119
120
121
# File 'lib/msf/core/exceptions.rb', line 119

def index
  @index
end

#stub_sizeObject (readonly)

Returns the value of attribute stub_size


119
120
121
# File 'lib/msf/core/exceptions.rb', line 119

def stub_size
  @stub_size
end

Instance Method Details

#to_sObject


104
105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/msf/core/exceptions.rb', line 104

def to_s
  # Deal with elements of a String being an instance of String instead of
  # Integer in ruby 1.9.
  if (char.respond_to? :ord)
    c = char.ord
  else
    c = char
  end
  if (c)
    return "Encoding failed due to a bad character (index=#{index}, char=#{sprintf("0x%.2x", c)})"
  else
    return "Encoding failed due to a nil character"
  end
end