28 lines
967 B
Diff
28 lines
967 B
Diff
# UNDF: UNDF-2026-000000907
|
|
--- a/src/gui/gui-nicklist.c
|
|
+++ b/src/gui/gui-nicklist.c
|
|
@@ -596,7 +596,12 @@
|
|
*
|
|
* Return pointer to new nick, NULL if error.
|
|
*/
|
|
-
|
|
+/*
|
|
+ * CWE-407: gui_nicklist_search_nick() performs O(N) linear scan
|
|
+ * through the nick linked list for dedup check on every add.
|
|
+ * When bulk-adding N nicks (e.g., joining a large IRC channel),
|
|
+ * this yields O(N^2) total work.
|
|
+ * Fix: maintain a hash table of nick names per buffer for O(1) lookup.
|
|
+ */
|
|
struct t_gui_nick *
|
|
gui_nicklist_add_nick (struct t_gui_buffer *buffer, long long id,
|
|
struct t_gui_nick_group *group,
|
|
@@ -604,7 +609,8 @@
|
|
{
|
|
struct t_gui_nick *new_nick;
|
|
|
|
- if (!buffer || !name || gui_nicklist_search_nick (buffer, NULL, name))
|
|
+ /* O(N) linear scan for dedup => O(N^2) when adding N nicks */
|
|
+ if (!buffer || !name || gui_nicklist_search_nick (buffer, NULL, name))
|
|
return NULL;
|
|
|
|
new_nick = malloc (sizeof (*new_nick));
|