This aligns the function with the documentation and what EPIC4/5 do. I couldn't find any example of an existing
script that actually called this function, so hopefully no-one is relying on the old behaviour.
The static 'pos' variable in check_flooding() would not stay in sync with the number of entries in
flood_list after clean_flood_list() was called. This meant that check_flooding() would always end up
removing all previous entries if it tried to add a new one.
Fix this by removing the tracking of number of flood_list entries, and just removing stale ones (older
than /SET FLOOD_RATE).
As always, the funcion pointers should be cast to the correct type before calling them, rather
than calling them with the wrong type and trying to cast the result. Fixes a warning compiling
mail.c on 64 bit architectures, and this might well have caused a crash when using the qmail plugin
on those architectures too.
Checking before truncation means you can sneak a privileged port past the check.
This change also collects the various broken-out parts of a CTCP DCC offer into a struct so that
it's easier to pass them all around together.
parse_offer_params() was being run unconditionally by check_dcc_init() even if it didn't find a
custom init_func() to call, which is the usual case. It then gets called again by the hardwired
DCC init function, which led to the error message appearing twice. This has check_dcc_init() only
call parse_offer_params() when its about to dispatch to a custom init func.
This also improves the message a bit (making it [host:port] rather than the other way around) and
combines the 'privileged port' message and "zero address" message together.
Previously waiting (inactive) file-type offers were shown different to others, omitting the
time-since-offer. Unify them to use the same format, which also cuts out a few lines of code.
Also tweaks the DCC_BAR_TYPE 1 format to include the DCC state (always Active) where the
completion bar would be in the DCC_BAR_TYPE 0 format. This just looks a bit more consistent.
s->time on the SocketList is set to the time that the chat offer will expire, so it's in the future.
This shows up as a very large positive time. Instead, use n->lasttime as that is set to the time
when the offer is made.
Also adjust the format for non-file offers so that it all lines up properly.
This now calculates a 'pcomplete' value for proportion of transfer complete (0.0 to 1.0).
From this we can calculate most other things easily - percent complete, ETA, and the size
of the completion bars.
User-visible change is that the DCC_BAR_TYPE 1 bar now matches the % complete for the RESUMEd
file case.
The only user-visible change here is that the bar displayed for DCC_BAR_TYPE 1 is now shown
as empty for a zero-length file rather than full, matching the 0.0% complete that is shown
and the bar displayed in the DCC_BAR_TYPE 0 case.
With DCC_BAR_TYPE 1 set, the stat line for active DCC file connections was not aligned
correctly with the header (the mm:ss field spilled into the KB/s column.)
This also simplifies things by always generating the inline bar, so the only difference
between the line printed for DCC_BAR_TYPE 0 and 1 is now the format itself.
There's no reason you shouldn't be able to use modelock as a half-op.
Also a few other minor cleanups in this function - eg. use my_send_to_server()
with the passed server number instead of implicitly using from_server.
glob_commands() would run off the end of the irc_command array if given a match that matched
the last command. It also leaked memory because it used m_s3cat() to construct the string,
then passed that to m_strdup().
This fixes these problems by reworking glob_commands(), and at the same time removes the use
of alloca() and wild_match() by using strncmp() instead to match the start of a string. Move
glob_commands() to alias.c and make it static since it's only used for aliasctl().
Change the 'name' argument of find_command() and find_dll_command() to const char * at the same
time, so that glob_commands()'s prefix argument can be const char * too.
cdcc_numpacks is unsigned, so %u should be used instead of %d.
Fix some memory leaks in /CDCC PLIST and /CDCC NOTICE where malloc_sprintf() was called
and the string never freed.
Identifiers beginning with two underscores or one underscore and a capital
letter are reserved in all contexts, including macros.
The __N macro in irc_std.h is in this space, and was conflicting with a macro
definition in gcc 5.4.0's xmmintrin.h under cygwin, making the build fail.
Reported-By: ice-man
These commands use prepare_command() to find a channel to act on, which returns the server to use.
The code should then use my_send_to_server() to ensure that it sends the command to that server -
these functions were using send_to_server() which sends to 'from_server', which means that they
could send the commands to the wrong place, for example if they were called from a hook on a
different server.
This patch was created with the following coccinelle script:
// Detects pairing preprare_command() with send_to_server() (which uses from_server)
@prepare3@
identifier s;
local idexpression c;
expression E1, E2, E3, E4, E5;
@@
(
if ((c = prepare_command(&s,...)) != NULL && ...)
{
<...
(
- send_to_server(E1);
+ my_send_to_server(s, E1);
|
- send_to_server(E1,E2);
+ my_send_to_server(s, E1, E2);
|
- send_to_server(E1,E2,E3);
+ my_send_to_server(s, E1, E2, E3);
|
- send_to_server(E1,E2,E3,E4);
+ my_send_to_server(s, E1, E2, E3, E4);
|
- send_to_server(E1,E2,E3,E4,E5);
+ my_send_to_server(s, E1, E2, E3, E4, E5);
)
...>
}
|
if ((c = prepare_command(&s,...)) == NULL || ...) { ... return ...; }
{
<...
(
- send_to_server(E1);
+ my_send_to_server(s, E1);
|
- send_to_server(E1,E2);
+ my_send_to_server(s, E1, E2);
|
- send_to_server(E1,E2,E3);
+ my_send_to_server(s, E1, E2, E3);
|
- send_to_server(E1,E2,E3,E4);
+ my_send_to_server(s, E1, E2, E3, E4);
|
- send_to_server(E1,E2,E3,E4,E5);
+ my_send_to_server(s, E1, E2, E3, E4, E5);
)
...>
}
)
This fixes several issues with the implied operators when NEW_MATH is enabled:
* None of the implied operators were returning the correct value, which should be the value
assigned to the LHS.
* The &&=, ||= ad ^^= operators were also operating on uninitialized variables and so behaving
unpredictably.
* The /= and %= operators would crash the client when the RHS was zero, because after outputting
the "Divide by zero" error they would go on to perform the operation anyway.
This FSET has existed for a long while but has been unused for some time,
since before the userlist was reworked to use flags instead of levels. This
means that the default value for the FSET also has to be updated.
The RELSN format already existed but wasn't used - instead it used SEND_NOTICE. The other relay
types already used similar formats for their relayed messages.
The default /FSET RELSN looks just like the default /FSET SEND_NOTICE so this shouldn't be
noticeable to anyone using the defaults.
This required updating the NOTICE-sending code to correctly stash the 'to' in the right place.
This switches from somewhat gory string parsing based on strncmp() and next_arg() to a simpler alternative
based on sscanf(). I think these are much easier to understand now, and shouldn't have any subtle bugs
lurking like the old code.
This also removes support for some obsolete messages that don't seem to be in any modern ircds:
"Identd reponse differs"; bot messages like "Rejecting vlad/joh/com bot:" except for "is a possible spambot"
which is still in use; and the "High-traffic mode" messages.
Previously, SWATCH NONE meant "show no server notices" if OperView was
enabled, but "show all server notices" if OperView was disabled. Now,
it always means "show no server notices" (the default SWATCH is ALL,
so the default will behave the same).
This allows us to simplify the code a great deal as well.
Also trim off leading "***" if the server messages are handled by
handle_oper_vision(), as they already are in parse_server_notice().
serversay() calls add_last_type(), so there's no need for the callers to do so
as well.
Remove the first argument to serversay() because it was always called with 1
anyway.
This was broken in commit [07cdd587], where 'sizeof' was used on a pointer
instead of the buffer pointed-to.
Fix this by having the caller of ircop_flags_to_str() supply a buffer and
length, since there's only two callers and both can use happily use stack
objects.
Remove the extra space in the default /fset SERVER_NOTICE, and similarly
the extra space in the HUMBLE /set SERVER_PROMPT.
The code in the client always _intended_ to add a space between SERVER_PROMPT
and SERVER_NOTICE_FSET but a bug in 75p3 and below meant it that it didn't.
This bug was fixed in 1.0b but the formats were never updated.
Also remove replace the embedded ANSI in the default SERVER_PROMPT with
% color code.
We don't know the server's proper name until registration, so the test against
that isn't reliable. We shouldn't be able to receive messages from anyone else
until we're registered, so this should be safe.
This requires changing serversay() to accept the from name instead of the
from_server. While we're there, replace the use of alloca() with simpler
logic based on m_sprintf().
This hook and format are used for NOTICEs where the destination isn't
a channel and isn't yourself - eg. global targets like $$*.org. This was
already the case for PRIVMSGs (using the MSG_GROUP hook and format).
Previously these were being routed like a normal NOTICE, and those don't
display the target, so it looked exactly like a private NOTICE to you.
This will also catch server notices sent before you're registered.
Some systems need <sys/sockio.h> for the SIOCGIFCONF ioctl - this switches
to using a proper configure check for that header rather than just assuming
it'll be there if we can't find SIOCGIFCONF. Should be more robust.
Instead of showing a meaningless pointer value for Screen:, we show the
screen number and ttyname.
Also take the CO, LI values from the window's screen.
Don't show the Prompt: unless one is set.
Someone reported being unable to connect with the error "Address family not
supported", which is probably being returned by socket(). It is likely a
system where getaddrinfo() is returning AF_INET6 addresses, but socket()
won't create AF_INET6 sockets.
To handle this case, we loop over all the addresses returned by getaddrinfo()
until we find one that socket() will accept.
This ensures that the saved-set-gid is also set, although this shouldn't
matter in practice since we always call execve() soon after, which
overwrites the saved-set-gid with the effective gid anyway.
This improves the client messages - eg previously the message to tell you that
you could use /DCC RESUME never got shown due to a logic error.
It also won't try to auto-resume if the local file is already the same size or
bigger than the incoming file.
Mark DCC connections that we have requested RESUME on, so that we know
whether or not to act on a DCC ACCEPT that is received.
Also fixes up a slightly wrong message in /DCC RESUME.
This also fixes a few others - eg /KBI now kicks-then-bans, and
/BKI bans-then-kicks (previously these were the wrong way around).
Reported by profiler.
The old code created a new stack frame in parse_line_alias_special(), then
another one in parse_line(). This prevented $functioncall() from working,
and made the output of CALL look odd.
|Rain| mentioned this years ago in starman.irc.
close_server() should call clear_server_queues() on the server that's being
closed, not from_server. This also lets us remove a few other calls to
clear_server_queues() that are right next to calls to close_server().
Channel WALL notices now have to match "[%Wall%/%] *", and have to be for
a channel that the client is actually on. Otherwise, they just appear as
ordinary NOTICEs.
We pass through ANSI just fine in PRIVMSGs, so we might as well treat
NOTICEs the same way too. The old code wasn't just stripping them out,
either - it was turning them into printable garbage.
Previously only send_kill() used BitchX.kill - the other KILL commands (eg.
/WHOKILL) were using the random kick reasons. Standardise them all on
BitchX.kill, and add this file to the source so it can be installed along
with the other random reason files.
Initialise ip_str so that it isn't used uninitialised.
Don't strip server flags from user@ portion of the hostmask, so that it will
not miss matching bans.
Switch ip_str from alloca() to malloc_sprintf() / new_free() - there's no
particular need for alloca() here.
A few places created strings based on the terminal width, using fixed-sized
buffers and without checking for overflowing them. Fix those, and also
replace all other sprintf() calls with snprintf().
Reported by cpet.