Skip to content

Commit c196cac

Browse files
committed
Merge remote branch 'jlee-r7/bug/rm7037-hash-iteration'
Hopefully I have the commit message hook right now. [Fixes #39207979]
2 parents 3df9dfc + 57bb23c commit c196cac

File tree

4 files changed

+72
-148
lines changed

4 files changed

+72
-148
lines changed

lib/msf/core/module_set.rb

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -169,12 +169,14 @@ def on_module_reload(mod)
169169
end
170170

171171
# @!attribute [rw] postpone_recalc
172-
# Whether or not recalculations should be postponed. This is used from the context of the each_module_list
173-
# handler in order to prevent the demand # loader from calling recalc for each module if it's possible that more
174-
# than one module may be loaded. This field is not initialized until used.
172+
# Whether or not recalculations should be postponed. This is used
173+
# from the context of the {#each_module_list} handler in order to
174+
# prevent the demand loader from calling recalc for each module if
175+
# it's possible that more than one module may be loaded. This field
176+
# is not initialized until used.
175177
#
176-
# @return [true] if recalculate should not be called immediately
177-
# @return [false] if recalculate should be called immediately
178+
# @return [true] if {#recalculate} should not be called immediately
179+
# @return [false] if {#recalculate} should be called immediately
178180
attr_accessor :postpone_recalculate
179181

180182
# Dummy placeholder to recalculate aliases and other fun things.
@@ -217,10 +219,10 @@ def add_module(mod, name, modinfo = nil)
217219

218220
# TODO this isn't terribly helpful since the refnames will always match, that's why they are ambiguous.
219221
wlog("The module #{mod.refname} is ambiguous with #{self[name].refname}.")
220-
else
221-
self[name] = mod
222222
end
223223

224+
self[name] = mod
225+
224226
mod
225227
end
226228

lib/msf/core/modules/loader/base.rb

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ def load_module(parent_path, type, module_reference_name, options={})
125125
return false
126126
end
127127

128-
loaded = namespace_module_transaction(type + "/" + module_reference_name, :reload => reload) { |namespace_module|
128+
try_eval_module = lambda { |namespace_module|
129129
# set the parent_path so that the module can be reloaded with #load_module
130130
namespace_module.parent_path = parent_path
131131

@@ -173,29 +173,22 @@ def load_module(parent_path, type, module_reference_name, options={})
173173
return false
174174
end
175175

176-
ilog("Loaded #{type} module #{module_reference_name} under #{parent_path}", 'core', LEV_2)
176+
if reload
177+
ilog("Reloading #{type} module #{module_reference_name}. Ambiguous module warnings are safe to ignore", 'core', LEV_2)
178+
else
179+
ilog("Loaded #{type} module #{module_reference_name} under #{parent_path}", 'core', LEV_2)
180+
end
177181

178182
module_manager.module_load_error_by_path.delete(module_path)
179183

180184
true
181185
}
182186

187+
loaded = namespace_module_transaction(type + "/" + module_reference_name, :reload => reload, &try_eval_module)
183188
unless loaded
184189
return false
185190
end
186191

187-
if reload
188-
# Delete the original copy of the module so that module_manager.on_load_module called from inside load_module does
189-
# not trigger an ambiguous name warning, which would cause the reloaded module to not be stored in the
190-
# ModuleManager.
191-
module_manager.delete(module_reference_name)
192-
193-
# Delete the original copy of the module in the type-specific module set stores the reloaded module and doesn't
194-
# trigger an ambiguous name warning
195-
module_set = module_manager.module_set(type)
196-
module_set.delete(module_reference_name)
197-
end
198-
199192
# Do some processing on the loaded module to get it into the right associations
200193
module_manager.on_module_load(
201194
metasploit_class,

0 commit comments

Comments
 (0)