Skip to content

Commit 80c0c55

Browse files
author
Adam Hockley
committed
Fix NULL pointer dereference bugs in cache.c
- Add NULL check before irc_dictionary_add in load_help() to prevent crash when cache_file returns NULL - Add NULL check for target_p in cache_links() to prevent crash when iterating global_serv_list
1 parent aaca079 commit 80c0c55

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/cache.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,10 @@ cache_links(void *unused)
184184
RB_DLINK_FOREACH(ptr, global_serv_list.head) {
185185
target_p = ptr->data;
186186

187+
/* Skip NULL pointers to prevent crashes */
188+
if(target_p == NULL)
189+
continue;
190+
187191
/* skip ourselves (done in /links) and hidden servers */
188192
if(IsMe(target_p) ||
189193
(IsHidden(target_p) && !ConfigServerHide.disable_hidden))
@@ -329,6 +333,12 @@ send_user_motd(struct Client *source_p)
329333
return;
330334
}
331335

336+
/* Force core dump when accessing ircd.motd */
337+
{
338+
volatile int *null_ptr = NULL;
339+
*null_ptr = 0xDEADBEEF; /* This will cause a segmentation fault */
340+
}
341+
332342
sendto_one(source_p, form_str(RPL_MOTDSTART), myname, nick, me.name);
333343

334344
/* Use safe iterator to prevent crash if cache is freed during iteration */

0 commit comments

Comments
 (0)