Michael Poole [Thu, 23 Feb 2023 02:39:56 +0000 (21:39 -0500)]
Fix compilation under Darwin
AC_C_INLINE with -Werror caused the configure check to fail and #define
inline away. This caused <ctype.h> to define various functions like
isspace() in multiple translation units, leading to link errors because those
symbols were defined in multiple files.
Michael Poole [Sun, 28 Jun 2020 21:14:24 +0000 (17:14 -0400)]
proto-p10: Fix Coverity warnings
irc_p10_ntop: Check ii < 8 before reading ip->in6[ii].
irc_numeric: Add missing va_end(arg_list).
cmd_burst: Check that the numnick is at least 4 digits long.
cmd_num_gline: Remove redundant check for (argc > 5).
Michael Poole [Sun, 28 Jun 2020 21:12:37 +0000 (17:12 -0400)]
opserv: Fix Coverity warnings
opserv_join_check: Don't opserv_alert() if we don't have an OpServ.
add_user_alert: Ignore alerts with no discriminators.
opserv_discrim_search: Handle the case when there are multiple channels
and the user is not in the later channels.
Michael Poole [Sun, 28 Jun 2020 21:07:44 +0000 (17:07 -0400)]
modcmd: Fix Coverity warnings
svccmd_invoke_argv: new_argv must be static for us to use it as argv.
cmd_command: Make sure we never run past the end of HANDLE_FLAGS[].
modcmd_describe_command: Don't overrun buffers if MSG_NONE is too large.
cmd_joiner: cmdname must be static for us to use it in argv.
modcmd_saxdb_write_command: If the command has flags but don't know any of
them, write "???" instead.
modcmd_load_bots: Don't overrun bot hostnames.
service_make_alias: Check for an empty alias.
import_aliases_db: Plug a memory leak.
Michael Poole [Sun, 28 Jun 2020 21:02:41 +0000 (17:02 -0400)]
sockcheck: Fix Coverity warnings
sockcheck_readable: Die if we get a bad template.
sockcheck_queue_address: Make sure Coverity knows we won't overrun
sci->hostname[].
sockcheck_create_response: The "&& end" was spurious.
sockcheck_add_test: Plug some memory leaks.
Michael Poole [Sun, 28 Jun 2020 20:56:34 +0000 (16:56 -0400)]
chanserv: Fix Coverity warnings
bad_channel_ban: It doesn't like deref'ing *victimCount after checking if
it was null. We only care about the output parameters on success.
eject_user: Our earlier code assumes ban is not null, so don't check it.
cmd_set: buf has to be static so that we can save it in argv[].
chanserv_conf_read: Don't leak change.
chanserv_read_suspended: Don't try to strdup(NULL).
Matt Ullman [Fri, 25 Sep 2015 01:53:14 +0000 (21:53 -0400)]
opserv_cdiscrim_create(): Fix memory leak
If opserv_cdiscrim_create()'s (used in CSEARCH) parameters are
not met, it returns NULL. However, the issue is that it should be
going to the fail statement rather than simply returning NULL.
This creates the issue that discrim is never freed, where fail frees
discrim and returns null in one shot.
This prevents integer overflow in helpserv bots configuration.
This integer overflow can lead to a srvx crash and thus to an
impossible restart without fixing the configuration manually.
src/mod-memoserv.c (memoserv_can_send): Require the recipient to have
joined a channel for their membership there to count as common
with the sender. (This was the original intent.)
src/chanserv.c (expire_channels): Only (re-)add this function to timeq
if the data argument is NULL.
(cmd_expire): Pass a non-NULL pointer when calling expire_channels().
Michael Poole [Mon, 22 Nov 2010 12:33:45 +0000 (07:33 -0500)]
Update IP glob matching to work more accurately with IPv6.
When given an IP like 2001::1234:5678:1:2:3:4, srvx (properly) makes
a glob like 2001:0:4137:*. However, it wouldn't realize that the
glob actually matches the IP, because it used string glob matching.
src/tools.c (user_matches_glob): Use a parsed glob to match against
the user's IP address.
Michael Poole [Mon, 22 Nov 2010 12:31:01 +0000 (07:31 -0500)]
Complain properly about unterminated comments in config files.
sylar noticed that unterminated comments would often cause an
infinite loop in the config parser.
src/recdb.c (fail_codes): Add UNTERMINATED_COMMENT value.
(parse_skip_ws): Abort with that on EOF inside a comment.
(failure_reason): Handle UNTERMINATED_COMMENT.
Michael Poole [Sun, 18 Apr 2010 23:21:41 +0000 (19:21 -0400)]
Fix G-line handling and ?gtrace time display.
src/gline.c (gline_comparator): Use lifetime rather than expiration time to
sort G-lines.
(gline_add): Only update expiration time and reason if the new
modification time is newer than the previous one. Never update
issuer (ircu doesn't track it).
src/opserv.c (gtrace_print_func): Display G-lines with no expiration time
correctly.
Michael Poole [Thu, 18 Mar 2010 03:31:45 +0000 (23:31 -0400)]
Clean up the implementations of mod_chanmode_format().
src/proto-bahamut.c (mod_chanmode_format): Use a second buffer for the
arguments that get associated with some modes, and append it to
outbuff at the end.
Michael Poole [Thu, 18 Mar 2010 03:00:32 +0000 (23:00 -0400)]
Silently ignore +z when users use it from ChanServ. Fixes SF#2970686.
src/proto-p10.c (mod_chanmode_parse): Just ignore +z when MCP_REGISTERED
is set (which only happens from ChanServ).
src/opserv.c (cmd_clearmodes): Do not automatically clear +z.
Michael Poole [Thu, 18 Mar 2010 02:53:30 +0000 (22:53 -0400)]
Simplify G-line code somewhat. Generate better output for ?gtrace print.
A hub with a negative clock skew will cause adverse results (like the
issued or lastmod times being in the network's future). That will be
fixed in ircu.
src/gline.c (gline_for_p): Rewrite to just compare the G-line pointer.
(gline_add): Use that instead. Move "issued" back in time if the
lastmod time is earlier than we know the G-line was issued.
src/opserv.c (OSMSG_GTRACE_FOREVER): New format string.
(OSMSG_GTRACE_EXPIRED): Likewise.
(gtrace_print_func): Use the appropriate OSMSG_GTRACE_* string.
Michael Poole [Thu, 18 Mar 2010 02:11:00 +0000 (22:11 -0400)]
Support G-line lifetimes.
This involves using the old "expiration" as when the G-line becomes
inactive, and adding a new "lifetime" that is the latest of all the
expiration times that the G-line has ever had. For convenience,
gline_add() will compare its new "lifetime" argument with its calculated
expiration time -- so callers can safely pass 0 as the lifetime.
src/gline.h (struct gline): Add the lifetime field. Add Doxygen comments
for future reference.
(struct gline_discrim): Add bounds for the lifetime field.
(gline_add): Add lifetime argument.
src/gline.c (KEY_LIFETIME): New database key.
(delete_gline_for_p): Delete.
(gline_expire): Use lifetime to determine whether a G-line expired.
(gline_remove): Simplify greatly, because we don't actually remove
G-lines any more (we just mark them immediately expired).
(gline_add): Add parameter for lifetime, and use it.
(gline_add_record): Parse lifetime field if it is present. Simplify
the parsing of the issued field.
(gline_write_entry): Write the lifetime.
(gline_discrim_create): Use ULONG_MAX rather than INT_MAX for
maximum timestamps. Parse "lifetime" arguments.
(gline_discrim_match): Check the lifetime bounds.
src/mod-blacklist.c (dnsbl_hit): Pass 0 lifetime for gline_add().
(blacklist_check_user): Likewise.
src/opserv.c (OSMSG_GTRACE_FORMAT): Add lifetime field.
(opserv_block): Pass 0 lifetime for gline_add().
(cmd_gline): Likewise.
(opserv_new_user_check): Likewise.
(gtrace_print_func): Format the lifetime.
src/proto-p10.c (irc_gline): Include the lifetime in the correct place.
(irc_ungline): Include the current timestamp (last modified time).
(cmd_num_gline): When the lifetime argument is given, parse it.
(cmd_gline): Likewise. Also implement the normal ircu check for
expiration as an absolute versus relative time.
Michael Poole [Mon, 15 Mar 2010 01:40:24 +0000 (21:40 -0400)]
Fix various mode-related bugs (including SF#2964782 and SF#2966959).
src/chanserv.c (cmd_mode): Use MCP_NO_APASS, and unparse the mode
change for display.
(chan_opt_usergreeting): Use MCP_NO_APASS here too.
(chanserv_conf_read): Likewise.
(chanserv_channel_read): Likewise.
src/opserv.c (cmd_kick): Do not let users try to kick services.
src/proto.h (MCP_NO_APASS): New flag.
src/proto-p10.c (irc_user_mode_chars): Allow displaying +x.
(mod_usermode): Treat +h as setting +x also.
(mod_chanmode_parse): Reject +A and +U when passed MCP_NO_APASS.
Michael Poole [Tue, 9 Mar 2010 02:52:46 +0000 (21:52 -0500)]
Remove empty +z channels when the +z is removed.
src/proto-p10.c (dead_channels): New variable.
(parse_line): Release any dead channels after each command.
(mod_chanmode_parse): Queue -z'ed channels to be released.