wave16: nova/keystone/crystal/dovecot/wireshark CWE-407 patches + unit tests
nova-0001: scheduler/manager.py selected_hosts list → set (273x, CRITICAL) nova-0002: scheduler/host_manager.py lowered_hosts_to_force list → set (43x, HIGH) keystone-0001: api/users.py token_roles list → set (32x, HIGH) crystal-0001: syntax/parser.cr type_vars Array#includes? → Set (25x, CRITICAL) crystal-0002: semantic/restrictions.cr discarded Array#includes? → Set (5x, CRITICAL) dovecot-0001: mail-storage-hooks.c array_lsearch → sort+bsearch (4x, HIGH) wireshark-0001: proto_data.c GSList → wmem_map_t (8x, HIGH) 7 unit tests: 9/9 PASS
This commit is contained in:
parent
291620b115
commit
59ae52c7b4
12 changed files with 724 additions and 177 deletions
|
|
@ -0,0 +1,30 @@
|
|||
--- a/src/lib-storage/mail-storage-hooks.c
|
||||
+++ b/src/lib-storage/mail-storage-hooks.c
|
||||
@@ -119,12 +119,21 @@ static void mail_user_add_plugin_hooks(struct mail_user *user)
|
||||
const struct mail_storage_module_hooks *module_hook;
|
||||
ARRAY(struct mail_storage_module_hooks) tmp_hooks;
|
||||
const char *name;
|
||||
+ ARRAY_TYPE(const_string) sorted_plugins;
|
||||
+
|
||||
+ /* Build a sorted copy of mail_plugins for O(log P) binary search.
|
||||
+ Avoids O(H×P) from array_lsearch inside the array_foreach loop
|
||||
+ (H = module_hooks count, P = mail_plugins count). */
|
||||
+ if (array_is_created(&user->set->mail_plugins)) {
|
||||
+ t_array_init(&sorted_plugins, array_count(&user->set->mail_plugins));
|
||||
+ array_append_array(&sorted_plugins, &user->set->mail_plugins);
|
||||
+ array_sort(&sorted_plugins, i_strcmp_p);
|
||||
+ }
|
||||
|
||||
/* first get all hooks wanted by the user */
|
||||
t_array_init(&tmp_hooks, array_count(&module_hooks));
|
||||
array_foreach(&module_hooks, module_hook) {
|
||||
if (!module_hook->forced) {
|
||||
name = module_get_plugin_name(module_hook->module);
|
||||
if (!array_is_created(&user->set->mail_plugins) ||
|
||||
- array_lsearch(&user->set->mail_plugins, &name,
|
||||
- i_strcmp_p) == NULL)
|
||||
+ array_bsearch(&sorted_plugins, &name,
|
||||
+ i_strcmp_p) == NULL)
|
||||
continue;
|
||||
}
|
||||
array_push_back(&tmp_hooks, module_hook);
|
||||
Loading…
Add table
Add a link
Reference in a new issue