Fixes #356. Delete poorly formatted reference entries, preventing bad reference objects from being stored in the actual module

git-svn-id: file:///home/svn/framework3/trunk@7172 4d416f70-5f16-0410-b530-b9f4589650da
unstable
HD Moore 2009-10-17 05:25:29 +00:00
parent efe44ba6b5
commit ce25403e18
1 changed files with 23 additions and 4 deletions

View File

@ -109,13 +109,14 @@ class Module
# Initialize module compatibility hashes
init_compat
# Fixup module fields as needed
info_fixups
# Transform some of the fields to arrays as necessary
self.author = Author.transform(module_info['Author'])
self.arch = Rex::Transformer.transform(module_info['Arch'], Array,
[ String ], 'Arch')
self.arch = Rex::Transformer.transform(module_info['Arch'], Array, [ String ], 'Arch')
self.platform = PlatformList.transform(module_info['Platform'])
self.references = Rex::Transformer.transform(module_info['References'], Array,
[ SiteReference, Reference ], 'Ref')
self.references = Rex::Transformer.transform(module_info['References'], Array, [ SiteReference, Reference ], 'Ref')
# Create and initialize the option container for this module
self.options = OptionContainer.new
@ -578,6 +579,24 @@ protected
c['Encoder'].update(module_info['EncoderCompat'] || {})
c['Nop'].update(module_info['NopCompat'] || {})
end
#
# Register options with a specific owning class.
#
def info_fixups
# Each reference should be an array consisting of two elements
refs = module_info['References']
if(refs and not refs.empty?)
refs.each_index do |i|
if(not (refs[i].respond_to?('[]') and refs[i].length == 2))
refs[i] = nil
end
end
# Purge invalid references
refs.delete(nil)
end
end
#
# Register options with a specific owning class.