Exception: Msf::BadcharError

Inherits:
EncodingError show all
Defined in:
lib/msf/core/exception.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

Returns a new instance of BadcharError.



106
107
108
109
110
111
# File 'lib/msf/core/exception.rb', line 106

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.



128
129
130
# File 'lib/msf/core/exception.rb', line 128

def buf
  @buf
end

#charObject (readonly)

Returns the value of attribute char.



128
129
130
# File 'lib/msf/core/exception.rb', line 128

def char
  @char
end

#indexObject (readonly)

Returns the value of attribute index.



128
129
130
# File 'lib/msf/core/exception.rb', line 128

def index
  @index
end

#stub_sizeObject (readonly)

Returns the value of attribute stub_size.



128
129
130
# File 'lib/msf/core/exception.rb', line 128

def stub_size
  @stub_size
end

Instance Method Details

#to_sObject



113
114
115
116
117
118
119
120
121
122
123
124
125
126
# File 'lib/msf/core/exception.rb', line 113

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