mirror of
https://github.com/ZoiteChat/zoitechat.git
synced 2026-03-22 05:30:18 +00:00
Fix oob read caused by ptr[0] being NULL in inbound_notice
If ptr[0] is NULL, then strchr may return a pointer to the NULL
terminator for serv->nick_prefixes, making the if statement true, which
then leads to the pointer increment leaving ptr oob. Now we check to
ensure ptr[0] != NULL.
From the Linux manpages for strchr:
The terminating null byte is considered part of the string, so that if c is
specified as '\0', these functions return a pointer to the terminator.
This commit is contained in:
@@ -940,7 +940,7 @@ inbound_notice (server *serv, char *to, char *nick, char *msg, char *ip, int id,
|
|||||||
sess = find_channel (serv, ptr);
|
sess = find_channel (serv, ptr);
|
||||||
|
|
||||||
/* /notice [mode-prefix]#channel should end up in that channel */
|
/* /notice [mode-prefix]#channel should end up in that channel */
|
||||||
if (!sess && strchr(serv->nick_prefixes, ptr[0]) != NULL)
|
if (!sess && ptr[0] && strchr(serv->nick_prefixes, ptr[0]) != NULL)
|
||||||
{
|
{
|
||||||
ptr++;
|
ptr++;
|
||||||
sess = find_channel (serv, ptr);
|
sess = find_channel (serv, ptr);
|
||||||
|
|||||||
Reference in New Issue
Block a user