Project

General

Profile

Enhancement #750 » 0018-sanitize-more-NULL-pointer-failsafes.patch

Loïc Gomez, 2022-01-10 19:28

View differences:

src/irc.c
char *ret;
size_t len;
assert(mask);
if (!mask)
return NULL;
while (*nick && *nick != '!')
nick++;
......
if (!l->origin)
return 0;
nick = nick_from_ircmask(l->origin);
if (!nick)
return 0;
if (strcasecmp(nick, server->nick) == 0) {
free(nick);
return 1;
......
return ERR_PROTOCOL;
s_nick = nick_from_ircmask(line->origin);
// should not happen
if (!s_nick)
return ERR_PROTOCOL;
hash_insert(&channel->ovmasks, s_nick, 0);
free(s_nick);
return OK_COPY;
......
if (!line->origin)
return ERR_PROTOCOL;
s_nick = nick_from_ircmask(line->origin);
// should not happen
if (!s_nick)
return ERR_PROTOCOL;
if (!hash_includes(&channel->ovmasks, s_nick)) {
free(s_nick);
return ERR_PROTOCOL;
......
char *nick;
nick = nick_from_ircmask(line->origin);
// should not happen
if (!nick)
return;
if (irc_line_elem_equals(line, 2, "\001VERSION\001")) {
WRITE_LINE2(CONN(server), NULL, "NOTICE", nick,
"\001VERSION bip-" PACKAGE_VERSION "\001");
......
return ERR_PROTOCOL;
org_nick = nick_from_ircmask(line->origin);
// should not happen
if (!org_nick)
return ERR_PROTOCOL;
dst_nick = irc_line_elem(line, 1);
for (hash_it_init(&server->channels, &hi); hash_it_item(&hi);
......
if (!line->origin)
return ERR_PROTOCOL;
s_nick = nick_from_ircmask(line->origin);
// should not happen
if (!s_nick)
return ERR_PROTOCOL;
for (hash_it_init(&server->channels, &hi); hash_it_item(&hi);
hash_it_next(&hi)) {
channel = hash_it_item(&hi);
(17-17/24)