Skip to content
This repository was archived by the owner on Jun 24, 2021. It is now read-only.

Commit df4f6d4

Browse files
committed
filter: fix part handling
previously we would have formatted a null pointer into %s for the command, which is theoretically bad but handled by glibc
1 parent 2b18069 commit df4f6d4

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

extensions/filter.c

+4-3
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ static int filter_enable = 1;
7070
static const char *cmdname[MESSAGE_TYPE_COUNT] = {
7171
[MESSAGE_TYPE_PRIVMSG] = "PRIVMSG",
7272
[MESSAGE_TYPE_NOTICE] = "NOTICE",
73+
[MESSAGE_TYPE_PART] = "PART",
7374
};
7475

7576
enum filter_state {
@@ -343,6 +344,8 @@ unsigned match_message(const char *prefix,
343344
return 0;
344345
if (!filter_db)
345346
return 0;
347+
if (!command)
348+
return 0;
346349
snprintf(check_buffer, sizeof check_buffer, "%s:%s!%s@%s#%c %s %s :%s",
347350
prefix,
348351
#if FILTER_NICK
@@ -361,8 +364,7 @@ unsigned match_message(const char *prefix,
361364
"*",
362365
#endif
363366
source->user && source->user->suser[0] != '\0' ? '1' : '0',
364-
command, target,
365-
msg);
367+
command, target, msg);
366368
hs_error_t r = hs_scan(filter_db, check_buffer, strlen(check_buffer), 0, filter_scratch, match_callback, &state);
367369
if (r != HS_SUCCESS && r != HS_SCAN_TERMINATED)
368370
return 0;
@@ -464,4 +466,3 @@ on_client_exit(void *data_)
464466
state = filter_db ? FILTER_LOADED : FILTER_EMPTY;
465467
}
466468
}
467-

0 commit comments

Comments
 (0)